1
如何將Visual Studio Solution(.sln)作爲輸入並獲取其中包含的所有項目的列表?如何搜索它包含的所有項目的Visual Studio解決方案?
如何將Visual Studio Solution(.sln)作爲輸入並獲取其中包含的所有項目的列表?如何搜索它包含的所有項目的Visual Studio解決方案?
這只是一個文本文件。在文本編輯器中打開它並查看。你正在尋找所有的項目指令。編寫一個簡單的解析器來提取* .vcproj名字應該不難。
這個數組將會給你完整的解決方案的細節用在解決方案中創建項目...
public List<string> getAllProjectNames(string path)
{
string[] arr = System.IO.File.ReadAllLines(path);
List<string> projects = new List<string>();
for (int i = 0; i < arr.Length; i++)
{
if (arr[i].StartsWith("Project"))
{
string [] temp = arr[i].Split(',');
projects.Add(temp[1]);
}
}
return projects;
}
調用此方法像...
List<string> Arr = getAllProjectNames(@"D:\Projects\PersonalRD\SearchingList\SearchingList.sln");
後,嘗試搜索所有項目名稱字符串項目以項目開頭...
你想要做什麼? 最簡單的方法是:打開它,你會看到所有的項目。 – StampedeXV 2009-10-07 08:42:59