What you can do is first read the solutiin file and get the included projects
If you open the solution file using notepad you ill notice that the project listed as the folow
Project("{00000000-0000-0000-0000-000000000000}") = "project name", "project path", "{00000000-0000-0000-0000-000000000000}"
So for example you can use reguler expretion to get a list of the projects
after you get the list of the projects you can read the project file and ge a list of all code files
the project file is in xml format
string solutionFile="the solution file";FileInfo fInfo = new FileInfo(solutionFile);
string solutionText = File.ReadAllText(solutionFile);
Regex reg = new Regex("Project\\(\"[^\"]+\"\\) = \"[^\"]+\", \"([^\"]+)\", \"[^\"]+\"");
MatchCollection mc = reg.Matches(solutionText);
List<string> files = new List<string>();
foreach (Match m in mc)
{
string project_file = m.Groups[1].Value;
project_file = System.IO.Path.Combine(fInfo.Directory.FullName, project_file);
if (System.IO.File.Exists(project_file))
{
string project_path = new FileInfo(project_file).DirectoryName;
XmlDocument doc = new XmlDocument();
doc.Load(project_file);
XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("ms", "http://schemas.microsoft.com/developer/msbuild/2003");
System.Xml.XmlNodeList list = doc.ChildNodes[1].SelectNodes("//ms:ItemGroup/ms:Compile", ns);
foreach (XmlNode node in list)
{
files.Add(Path.Combine(project_path, node.Attributes["Include"].InnerText));
}
}
}
Update for references:
you can use this code to read the reference.
XmlNodeList references = doc.ChildNodes[1].SelectNodes("//ms:ItemGroup/ms:Reference", ns);
foreach (XmlNode node in references)
{
string name_space = node.Attributes["Include"].InnerText;
string name_space_path;
XmlNode nHintPath = node.SelectSingleNode("//ms:HintPath", ns);
if (nHintPath != null)
{
name_space_path = nHintPath.InnerText;
if (!Path.IsPathRooted(name_space_path))
{
name_space_path = Path.Combine(project_path, name_space_path);
}
}
}