User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Mar 2007
Posts: 93
Reputation: mrjoli021 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster in Training

append 2 file

  #1  
Jun 25th, 2008
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();
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 403
Reputation: selvaganapathy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 69
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro in Training

Re: append 2 file

  #2  
Jun 25th, 2008
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
//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
Reply With Quote  
Join Date: Mar 2007
Posts: 93
Reputation: mrjoli021 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mrjoli021 mrjoli021 is offline Offline
Junior Poster in Training

Re: append 2 file

  #3  
Jun 25th, 2008
U the man

it worked

Thx
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 10:50 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC