Make a file 'DependentUpon' via the IDE
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
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 );
}
}