Problem with System.IO.File

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • liran

    Problem with System.IO.File

    hello
    i am trying to create a new file and then to write to it. how can i
    create an new file? i tried System . IO.File but it returns an error
    as follows:
    System.IO.File. File() is inaccessible due to its protection level
  • Cordell Lawrence

    #2
    Re: Problem with System.IO.File

    There are a bit many ways to create a file. Here's one

    FileStream fileStream = System.IO.File. Create("example .txt");
    fileStream.Writ e(0xFF);

    the FileStream's write methods though really only allow you to write byte
    and arrays of bytes to the stream, if you wanna write strings you can use a
    StreamWriter along with the file stream;

    StreamWriter writer = new StreamWriter(fi leStream);
    writer.Write("H ello ");
    writer.WriteLin e("World !");

    HTH
    Cordell Lawrence
    Teleios Systems Ltd.

    "liran" <liranbaryoav@g mail.com> wrote in message
    news:440d4f8d.0 505121437.4d569 024@posting.goo gle.com...[color=blue]
    > hello
    > i am trying to create a new file and then to write to it. how can i
    > create an new file? i tried System . IO.File but it returns an error
    > as follows:
    > System.IO.File. File() is inaccessible due to its protection level[/color]


    Comment

    Working...