473,386 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

StreamWriter Creates File But Does not Add the Passed Text.

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",FileMo de.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
Nov 16 '05 #1
3 1421
John Tyce <jt***@chevrontexaco.com> wrote:
My stream writer is creating the file, but writes no text in it.


Are you flushing and closing the StreamWriter?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Thanks, but I figured it out.

--
JOHN TYCE
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
John Tyce <jt***@chevrontexaco.com> wrote:
My stream writer is creating the file, but writes no text in it.


Are you flushing and closing the StreamWriter?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
John Tyce <jt***@chevrontexaco.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Majed | last post by:
Hi , all I'm trying to write unicode to a file for another app (not developed with vs2003) to read it. I used StreamWriter with unicode encoding.but I was surprised that the streamwriter adds FFFE...
0
by: Sandy Beach | last post by:
Hi, I have an app, written in c#, that checks an email inbox (using cdo/mapi) and does some processing. I've written a function "WriteToLogFile (string text, bool onConsole)" that checks...
0
by: Grahame | last post by:
Hi, I have an app, written in c#, that checks an email inbox (using cdo/mapi) and does some processing. I've written a function "WriteToLogFile (string text, bool onConsole)" that checks...
4
by: ASP Yaboh | last post by:
I am using StreamWriter's .Writeline() method to create a simple text file. I found that ASCII characters 255 & 254 are being inserted as the first two characters of the file which causes a...
9
by: ShadowOfTheBeast | last post by:
Hi, I have got a major headache understanding streamReader and streamWriter relationship. I know how to use the streamreader and streamwriter independently. but how do you write out using the...
10
by: Oscar Thornell | last post by:
Hi, I generate and temporary saves a text file to disk. Later I upload this file to Microsoft MapPoint (not so important). The file needs to be in UTF-8 encoding and I explicitly use the...
2
by: sameer | last post by:
Hi, My very simple application VB.NET Visual Studio 2003 console application uses a log file to write some text to it. I am using StreamWriter object to create and open and then append text to...
1
by: Max Powers | last post by:
Hello, I have a VB.NET code that creates a StreamWriter file first and then it does a series of procedures that write lines for this StreamWriter. When all the procedures are done, the...
3
by: fniles | last post by:
I am using VB.NET 2005 and streamWriter to write to a file. Before writing to the file, I encrypt the string. StreamWriter does not write it correctly to the file, I have to change to FileOpen,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.