Hi Guys
NP121 StreamWriter & StreamReader
http://www.aspfree.com/c/a/C-Sharp/C-Sharp-StreamReader-and-StreamWriter-Explained/1/
In the above website program is “using StreamWriter to write to a file”. Article is continuing and there is a program “using StreamReader to read from the file”.
Contant of aFile.txt created by “using StreamReader to read from the file” is empty.
I wish to know whether aFile.txt created by “using StreamReader to read from the file” program is quite independent or program has to Read from aFile.txt created by program “using StreamWriter to write to a file”.
Please explain.
Thank you
AlanPosted Aug 13, 2008, 8:41 AM
Ah, I think the problem there is that aFile.txt is being created (by default) in the application directory.
So, the second program won't be able to find the first aFile.txt (created in the first program's application folder) and will create a new empty one.
What you need to do therefore is replace aFile.txt with a full absolute path so that both programs will use the same file. Alternatively, just copy the file manually into the second program's application folder.
Posted Aug 13, 2008, 8:25 AM
Even though I did like as you said aFile.txt is empty. I tried both with Microsoft Visual C# 2008 Express Edition & Microsoft Visual C# 2008 Express Edition but result is same.
AlanPosted Aug 13, 2008, 8:04 AM