CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: C#

  1. #1
    Join Date
    May 2001
    Posts
    1

    C#

    In c# , How can we open a file in write mode and write into it.


  2. #2
    Join Date
    Jun 2001
    Location
    Vietnam
    Posts
    2

    Re: C#

    Hi,
    You can use FileStream class to create or open file and use StreamWriter class to write into file.

    Here is an example :

    using System.IO;

    class TestWriteFile
    {

    public static void Main()
    {

    FileStream fs = new FileStream("text.txt", FileMode.Create);
    StreamWriter w = new StreamWriter(fs);
    w.WriteLine("This is a test string");
    w.Flush();
    w.Close();
    fs.Close();
    }
    }


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

Featured