Add existing file to Visual Studio project using DTE

I programmed several files. I want to add them to a visual studio project. I have a link to a project (DTE.Project). When I execute the code below, an error message appears.

project.ProjectItems.AddFromFile(filename); 

Error

 Exception at 'Expand' - 'Unable to add 'manage.txt'. A file with that name already exists.' System.Runtime.InteropServices.COMException (0x80040400): Unable to add 'manage.txt'. A file with that name already exists. at EnvDTE.ProjectItems.AddFromFile(String FileName) 

When I transfer the call to try-catch, the process ends, but no files are added to the project. I need to manually show hidden files and then include them in the project.

How to add a file for this?

+4
source share
1 answer

@ritcoder - required:

I think this thread provides a solution for your question - Visual Studio Mask: find files that are not included in the project?

0
source

Source: https://habr.com/ru/post/1391115/


All Articles