G
Guest
Hello,
How can I give actual path of directory where my xml file exist? I want to
load a xml "progressbarsample.xml" from path "c:\manoj\". I read example on
page number 125 of book "Microsoft .NET COMPACT FRAMEWORK by Andy Wigley &
Stephen Wheelwright". The code written for path in book is as follows: -
Please help me where and how I should give actual path of xml file
"progressbarsample.xml" which is "c"\manoj\" in my case. When I compile
program it compiles successfully but when I run it give error message "File
not found" and stop at statement "while (xmlrdr.Read())".
Thank you.
private void button1_Click(object sender, System.EventArgs e)
{
label1.Text = "Loading... Please Wait";
//Force form to display label text change
Application.DoEvents();
//Assume this file is about 25000 nodes
progressBar1.Minimum = 250;
progressBar1.Maximum = 25000;
progressBar1.Value = progressBar1.Minimum;
//Get path to XML file - in same directory as this program
string path = System.Reflection.Assembly.GetExecutingAssembly().GetName
().CodeBase;
string xmlFileUrl = new FileInfo(path).DirectoryName
+@"\progressbarsample.xml";
XmlTextReader xmlrdr = new XmlTextReader(xmlFileUrl);
int readcount = 0;
while (xmlrdr.Read())
{
//do something ...
//Update progressbar every 100 reads
if ((++readcount % 100) == 0)
{
if (progressBar1.Value < progressBar1.Maximum)
progressBar1.Value += progressBar1.Minimum;
}
}
//complete
progressBar1.Value = progressBar1.Maximum;
label1.Text = "Complete!";
}
How can I give actual path of directory where my xml file exist? I want to
load a xml "progressbarsample.xml" from path "c:\manoj\". I read example on
page number 125 of book "Microsoft .NET COMPACT FRAMEWORK by Andy Wigley &
Stephen Wheelwright". The code written for path in book is as follows: -
Please help me where and how I should give actual path of xml file
"progressbarsample.xml" which is "c"\manoj\" in my case. When I compile
program it compiles successfully but when I run it give error message "File
not found" and stop at statement "while (xmlrdr.Read())".
Thank you.
private void button1_Click(object sender, System.EventArgs e)
{
label1.Text = "Loading... Please Wait";
//Force form to display label text change
Application.DoEvents();
//Assume this file is about 25000 nodes
progressBar1.Minimum = 250;
progressBar1.Maximum = 25000;
progressBar1.Value = progressBar1.Minimum;
//Get path to XML file - in same directory as this program
string path = System.Reflection.Assembly.GetExecutingAssembly().GetName
().CodeBase;
string xmlFileUrl = new FileInfo(path).DirectoryName
+@"\progressbarsample.xml";
XmlTextReader xmlrdr = new XmlTextReader(xmlFileUrl);
int readcount = 0;
while (xmlrdr.Read())
{
//do something ...
//Update progressbar every 100 reads
if ((++readcount % 100) == 0)
{
if (progressBar1.Value < progressBar1.Maximum)
progressBar1.Value += progressBar1.Minimum;
}
}
//complete
progressBar1.Value = progressBar1.Maximum;
label1.Text = "Complete!";
}