Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Here's a collection of small code samples on different ways to work with projects.
Get project from contained file
This is how to get the project from one of its files.
string fileName = "c:\\file\\in\\project.txt";
PhysicalFile item = await PhysicalFile.FromFileAsync(fileName);
Project project = item.ContainingProject;
Add files to project
Here's how to add files from disk to the project.
Project project = await VS.Solutions.GetActiveProjectAsync();
var file1 = "c:\\file\\in\\project\\1.txt";
var file2 = "c:\\file\\in\\project\\2.txt";
var file3 = "c:\\file\\in\\project\\3.txt";
await project.AddExistingFilesAsync(file1, file2, file3);
Find type of project
Find out what type of project you're dealing with.
bool isCsharp = await project.IsKindAsync(ProjectTypes.CSHARP);