Click here to Skip to main content
15,884,007 members
Home / Discussions / C#
   

C#

 
GeneralRe: DotSpatial.Positioning.NmeaInterpreter Pin
Eddy Vluggen1-Mar-13 5:10
professionalEddy Vluggen1-Mar-13 5:10 
Questionsdk Pin
RAJESHSELVARAJ28-Feb-13 23:04
RAJESHSELVARAJ28-Feb-13 23:04 
AnswerRe: sdk Pin
Pete O'Hanlon28-Feb-13 23:24
mvePete O'Hanlon28-Feb-13 23:24 
AnswerRe: sdk Pin
Dave Kreskowiak1-Mar-13 2:21
mveDave Kreskowiak1-Mar-13 2:21 
QuestionIssue using the StreamWritter Class Pin
TwiztedFreek28-Feb-13 13:16
TwiztedFreek28-Feb-13 13:16 
AnswerRe: Issue using the StreamWritter Class Pin
TwiztedFreek28-Feb-13 13:18
TwiztedFreek28-Feb-13 13:18 
AnswerRe: Issue using the StreamWritter Class Pin
Garth J Lancaster28-Feb-13 14:08
professionalGarth J Lancaster28-Feb-13 14:08 
AnswerRe: Issue using the StreamWritter Class Pin
Jegan Thiyagesan28-Feb-13 23:33
Jegan Thiyagesan28-Feb-13 23:33 
Hi,
The answer to your question is to set the stream writer to append mode.
Try this:

C#
string _fileName  = "TestFile2.txt";
private void summaryButton_Click(object sender, EventArgs e)
{
    //Displays the summary text file in a label for the user to read
    //First a simple test of the file writting
    bool Flag = true;
    if (Flag)
    {
        string content = string.Format("This is a test {0}", todayDate.ToString());
        writeToFile(_fileName, content);
    }
    else
    {
        MessageBox.Show("ERROR");
    }
 
}

private void writeToFile(string fileName, string content)
{
    FileInfo fi = new FileInfo(fileName);

    // Check that the file exists first
    if (!fi.Exists)
    {
        MessageBox.Show("file doesn't exists!");
        return;
    }
    else
    {
        using (StreamWriter sw = new StreamWriter(fileName, true, System.Text.Encoding.Default))
        {
            sw.Write(content);
        }
    }
}


Hope this helps.

Regards
Jegan
Think! Don't write a line of code unless you absolutely need to.

AnswerRe: Issue using the StreamWritter Class Pin
Keith Barrow1-Mar-13 1:06
professionalKeith Barrow1-Mar-13 1:06 
AnswerRe: Issue using the StreamWritter Class Pin
Defens931-Mar-13 9:35
Defens931-Mar-13 9:35 
QuestionCopy username from text file to website Pin
Muhammad Sayyam28-Feb-13 2:17
Muhammad Sayyam28-Feb-13 2:17 
AnswerRe: Copy username from text file to website Pin
DaveyM6928-Feb-13 3:07
professionalDaveyM6928-Feb-13 3:07 
GeneralRe: Copy username from text file to website Pin
Richard MacCutchan28-Feb-13 3:23
mveRichard MacCutchan28-Feb-13 3:23 
GeneralRe: Copy username from text file to website Pin
DaveyM6928-Feb-13 10:30
professionalDaveyM6928-Feb-13 10:30 
GeneralRe: Copy username from text file to website Pin
Muhammad Sayyam2-Mar-13 20:19
Muhammad Sayyam2-Mar-13 20:19 
GeneralRe: Copy username from text file to website Pin
DaveyM695-Mar-13 3:08
professionalDaveyM695-Mar-13 3:08 
GeneralRe: Copy username from text file to website Pin
DaveyM697-Mar-13 21:51
professionalDaveyM697-Mar-13 21:51 
Questiontooth numbers Pin
Jassim Rahma28-Feb-13 0:35
Jassim Rahma28-Feb-13 0:35 
AnswerRe: tooth numbers PinPopular
Pete O'Hanlon28-Feb-13 1:11
mvePete O'Hanlon28-Feb-13 1:11 
AnswerRe: tooth numbers Pin
GuyThiebaut28-Feb-13 2:03
professionalGuyThiebaut28-Feb-13 2:03 
QuestionVS2012, C# Office 2007 problem Pin
Daytona67527-Feb-13 9:34
Daytona67527-Feb-13 9:34 
AnswerRe: VS2012, C# Office 2007 problem Pin
Richard MacCutchan27-Feb-13 21:58
mveRichard MacCutchan27-Feb-13 21:58 
AnswerRe: VS2012, C# Office 2007 problem Pin
OriginalGriff27-Feb-13 22:40
mveOriginalGriff27-Feb-13 22:40 
Questionc# field type is less accessible than field (SOLVED!) Pin
jojoba201127-Feb-13 9:25
jojoba201127-Feb-13 9:25 
AnswerRe: c# field type is less accessible than field Pin
Jibesh27-Feb-13 9:39
professionalJibesh27-Feb-13 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.