Hi all,
I am trying to create a VS project using C#. I am able to successfully create the same and save it to a location.
I have a requirement that I am not able to work through. After creating the project, I have to copy from files (from a physical file location) to folder under the project. The file needs to be copied physically as well as get added to the Project also. I am able to traverse the project and find the folder. I use this code :
Project proj = soln.Projects.Item(1);
ProjectItems items = proj.ProjectItems;
foreach (ProjectItem projectItem in items)
{
var i = projectItem.Kind.ToUpper();
if (i == DTEConstants.vsProjectItemKindPhysicalFolder)
{
var i1 = projectItem.Name;
if (i1 == "<<The Folder Name>>")
{
projectItem.ProjectItems.AddFromFile(@"<< File to Copy path>>");
}
}
}The file gets copied under the project , but when I open the project in VS the file is not included in the VS project. I need the file to be included into the project too.
Regards,
Girija
Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria