Create a file

Hi!

I'm creating a file in an aplication but when it creates it, the file is in blank.

Could you help me with some method to create a file

Thanks!


Answer this question

Create a file

  • Jules Bonnot

    What is the code you are using and what version of VB.NET are you using

  • vtortola

    Hi,
    Here is a simple way to create a file.
    You must imports system.IO;

    And some thing like that in VB.net to create a write on file...

    Dim sw as new StreamWriter("C:\\demo.txt");
    sw.WriteLine("Line 1");
    sw.WriteLine("Line 2");
    sw.Close();

    Hope this help.



  • tony noriega

    I assume theat your trying to create a simple text file or something similar to that.

    Dim s as string = "Text File Contents"
    My.Computer.Filesystem.WriteAllText("c:\tests.txt", s, False)

    My.Computer.Filesystem.Writealltext method
    http://msdn2.microsoft.com/en-us/library/27t17sxs.aspx


  • markovuksanovic

    Hi,

    I posted VB.net code here is VB6 code.

    Rem write
    Open "c:\demo.txt " For Output As #1
    Print #1, mySerial
    Close #1


    Rem read
    Open "c:\demo.txt" For Input As #1
    Input #1, mySerial
    Close #1

    Hope this help.



  • Create a file