StreamWriter Creates File But Does not Add the Passed Text.

  • Thread starter Thread starter John Tyce
  • Start date Start date
J

John Tyce

My stream writer is creating the file, but writes no text in it.


if(MyDataSet.Tables["USER_QUERYTABLE"] != null)

{



MyDataSet.WriteXml(@"C:\DISWin\Report\userdata.xml");

FileStream fs = new FileStream(@"C:\DISWin\Report\userdata.xml",FileMode.Open,FileAccess.Read);

//FileStream txtFS = new FileStream(@"C:\DISWin\Report\OutPut.txt",FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);

StreamWriter MyWriter = new StreamWriter(@"C:\DISWin\Report\OutPut.txt"); //(also tried passing the above FileStream her instead of path)



XmlTextReader xtr = new XmlTextReader(fs);

XmlDocument doc = new XmlDocument();

doc.Load(xtr);

XmlNodeList nodeLst;




string strCol = null;

int n = 0;

foreach(string item in mCol_Name)

{

if(item != null && item != "")

{

n = item.IndexOf(",",0);

string tag = item.Remove(n,1);

tag = tag.Trim();

nodeLst = doc.GetElementsByTagName(tag);

foreach(XmlNode node in nodeLst)

{

strCol = node.InnerText.ToString();

n = strCol.Length;

strCol = strCol.Remove(10,(n-10));

strCol = tag + " " + strCol;

MyWriter.WriteLine(strCol); (this produces no text in the output.txt file)



}

}

}
 
John Tyce said:
Thanks, but I figured it out.

So what was the problem? If you could say what you had to change, it
could help someone else with the same problem who may find your post
through groups.google.com in the future.
 
Back
Top