•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 403,029 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,827 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 812 | Replies: 2 | Solved
![]() |
•
•
Join Date: Mar 2007
Posts: 93
Reputation:
Rep Power: 2
Solved Threads: 0
i am having problems appending txt to a file. it overwrites the file instead of appending
private StreamWriter outputfile = new StreamWriter("c:\\testfile.txt");
public void SetFile()
{
this.outputfile.WriteLine("Test",FileMode.Append, FileAccess.Write);
this.outputfile.Close();
}
-----------------------------------------------------------------
main class
FileRead Testing1 = new FileRead();
Testing1.SetFile();•
•
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 403
Reputation:
Rep Power: 1
Solved Threads: 69
Hi,
I think There is no method of StreamWriter.WriteLine ( string, FileMode, FileAccess);
But you can open File in Append Mode in Constructor
StreamWriter ( string file, bool Append) ;
You Change the code as
Its working good.
I think There is no method of StreamWriter.WriteLine ( string, FileMode, FileAccess);
But you can open File in Append Mode in Constructor
StreamWriter ( string file, bool Append) ;
You Change the code as
//Append Mode
private StreamWriter outputfile = new StreamWriter("c:\\testfile.txt", true);
public void SetFile() {
this.outputfile.WriteLine("Test");
this.outputfile.Close();
}
-----------------------------------------------------------------
main class
FileRead Testing1 = new FileRead();
Testing1.SetFile();Its working good.
Last edited by selvaganapathy : Jun 25th, 2008 at 12:59 pm.
KSG
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- saving results to a txt file. (Java)
- Writing in a file (C++)
- Download File (ASP.NET)
- getting form elements to write to a file (Perl)
- Help with appending text file (VB.NET)
- Custom Class - File I/O (C++)
- Pascal : Access a file of 100 Quiz questions so 12 Random ones are displayed? (Pascal and Delphi)
- append to XML file (Visual Basic 4 / 5 / 6)
- file problem (C)
- Random Programming Script (Computer Science and Software Design)
Other Threads in the C# Forum
- Previous Thread: square root
- Next Thread: c# http client


Linear Mode