Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to check if file is included in Project

$
0
0

I have been using this code below to include the files to the project.

var project = new Project(projectFile);
project.AddItem("Compile", fileToAdd);
project.Save();

The file already exists in the project directory before the code is ran.

The problem is if the file is already included in the solution, and this is ran again, there will be a duplicate of the same file.

Is there are way to check if the file is already included in the solution?

The code below only checks if the file exists physically in the project folder, but not if it is included in the solution.

System.IO.File.Exists(pathToSourceFile)



Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>