Reading the .vcproj file with C#
Posted
by Dulantha Fernando
on Stack Overflow
See other posts from Stack Overflow
or by Dulantha Fernando
Published on 2010-06-05T18:48:12Z
Indexed on
2010/06/05
18:52 UTC
Read the original article
Hit count: 215
We create the vcproj file with the makefileproj keyword so we can use our own build in VS. My question is, using C#, how do you read the "C++" from the following vcproj file:
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="TestCSProj"
ProjectGUID="{840501C9-6AFE-8CD6-1146-84208624C0B0}"
RootNamespace="TestCSProj"
Keyword="MakeFileProj"
>
<Platforms>
<Platform
Name="x64"
/>
<Platform
Name="C++" ===> I need to read "C++"
/>
</Platforms>
I used XmlNode and got upto the second Platform:
String path = "C:\\blah\\TestCSProj\\TestCSProj\\TestCSProj.vcproj";
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(fs);
XmlNodeList oldFiles = xmldoc.GetElementsByTagName("Platform");
XmlAttribute name = oldFiles[1].Attributes[0];
Console.WriteLine(name.Name);
This will print Name, but I need "C++". How do I read that?
Thank you very much in advance
© Stack Overflow or respective owner