Results 1 to 4 of 4

Thread: [RESOLVED] Not able to write to a text file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Resolved [RESOLVED] Not able to write to a text file

    I am using following code. The file gets created but content of the file always empty. can some one correct my code?

    StreamWriter fileWriter; // writes data to text file
    FileStream output; // maintains connection to file

    string fileName = @"c:\apsdata\br\junk.txt";
    // open file with write access
    output = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
    // sets file to where data is written
    fileWriter = new StreamWriter(output);

    fileWriter.WriteLine(fileName);

    thanks
    nath

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Not able to write to a text file

    I assume you are closing the file properly before you attempt to read the file again?
    I don't live here any more.

  3. #3
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: Not able to write to a text file

    with fileWriter.Close();

  4. #4
    Junior Member
    Join Date
    Jun 2006
    Posts
    20

    Re: [RESOLVED] Not able to write to a text file

    try and check what happens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width