Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. string solutionFile="the solution file";FileInfo fInfo = new FileInfo(solutionFile);
  2. string solutionText = File.ReadAllText(solutionFile);
  3. Regex reg = new Regex("Project\("[^"]+"\) = "[^"]+", "([^"]+)", "[^"]+"");
  4. MatchCollection mc = reg.Matches(solutionText);
  5. List<string> files = new List<string>();
  6. foreach (Match m in mc)
  7. {
  8. string project_file = m.Groups[1].Value;
  9. project_file = System.IO.Path.Combine(fInfo.Directory.FullName, project_file);
  10. if (System.IO.File.Exists(project_file))
  11. {
  12. string project_path = new FileInfo(project_file).DirectoryName;
  13. XmlDocument doc = new XmlDocument();
  14. doc.Load(project_file);
  15. XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
  16. ns.AddNamespace("ms", "http://schemas.microsoft.com/developer/msbuild/2003");
  17. System.Xml.XmlNodeList list = doc.ChildNodes[1].SelectNodes("//ms:ItemGroup/ms:Compile", ns);
  18. foreach (XmlNode node in list)
  19. {
  20. files.Add(Path.Combine(project_path, node.Attributes["Include"].InnerText));
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement