I have a 3D object and their data points. Data consists of 1000 points.
The following are for the data points.
public static List<MyLine> OpenProject(string _file)
{
List<MyLine> Lines = new List<MyLine>();
XmlDocument doc = new XmlDocument();
doc.LoadXml(_file);
XmlNodeList coordinates = doc.SelectNodes("/Siene/MyLine/Coordinates");
foreach (XmlNode coordinat in coordinates)
{
int x1 = Int32.Parse(coordinat["Start"].Attributes["X"].Value);
int y1 = Int32.Parse(coordinat["Start"].Attributes["Y"].Value);
int z1 = Int32.Parse(coordinat["Start"].Attributes["Z"].Value);
MyLine czg = new MyLine(x1, y1, z1);
lines.Add(czg);
}
return lines;
}
Instead of loading from an external file (doc.LoadXml(_file), the XML file must be in solution explorer and all data points must be able to read from there.
Could you say me how it can be done.
Regards,
Mark Twain
In the solution
In your code
Lets say my assembly was called "Hello.World" and the file was embedded at the root of the project called "foo.xml" the you could use this code:
var myAss = Assembly.GetExecutingAssembly();
using (var s = myAss.GetManifestResourceStream(string.Format("{0}.foo.xml",
myAss.GetName().Name)))
{
var doc = new XmlDocument();
doc.Load(s);
}
You could embed the file as a resource:
Resource Files (Visual Studio)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.