Make a file 'DependentUpon' via the IDE

Easy question,
I can modify a C# project using notepad to make a file DependentUpon another file, but is there a way to do this in the IDE?
Thanks
[162 byte] By [kk302999] at [2008-3-5]
# 1
Nope.
VijayeRaji at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# IDE...
# 2
Ok, thanks.
kk302999 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# IDE...
# 3
Yes, you can...:)) The code below is from an add-in I developed, add-in which generates some files and adds them to a C# project and makes them dependent of the file they were generated from. I'm using it in VS 2005 Pro and it works wery well. Create a new Add-in project in VS 2005 and you'll see what are all classes presented here (DTE2, Project and so on); Of course, you can refine this example further...:P

private AddFileToProject( string tempFileName, bool ask )
{
private DTE2 _applicationObject;

Project currentProject =
_applicationObject.SelectedItems.Item( 1 ).ProjectItem.ContainingProject as Project;

localFile = Path.Combine(
Path.GetDirectoryName( currentProject.FullName ),
Path.GetFileName( tempFileName ) );

bool localFileExists = File.Exists( localFile );

if ( !ask ||
(ask && !localFileExists) ||
( ask && localFileExists && ShowOverwriteDialog( localFile ) == DialogResult.Yes ) )
{

// copy the file in the project directory
File.Copy( tempFileName, localFile, true );

// add to project
ProjectItem item = _applicationObject.SelectedItems.Item( 1 ).ProjectItem;
// add as "DependentUpon"
item.ProjectItems.AddFromFile( localFile );
// expand the files below the selected item
item.ExpandView();

// save the project
currentProject.Save( currentProject.FullName );
}
}

bdaniel7 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# IDE...