instance on io.file

akim

Member
Joined
Jul 6, 2003
Messages
10
Location
germany
hi,

i dont know how i can make an instance on io.file.

can you give me an example

at the moment i am using :

dim textfile as io.file
textfile.exists("C:\" & i)

but textfile is the object not the instance.


can anyone help me

thx

akim
 
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f As IO.File
        Select Case f.Exists("C:\test123.txt")
            Case True /// if it exsists put the text from it to a textbox.
                Dim sr As IO.StreamReader = New IO.StreamReader(New IO.FileStream("C:\test123.txt", IO.FileMode.Open))
                TextBox1.AppendText(sr.ReadToEnd)
                sr.Close()
            Case False ///if it doesnt exsist , create it and add some text to it.
                Dim sr As IO.StreamWriter = New IO.StreamWriter(New IO.FileStream("C:\test123.txt", IO.FileMode.Create))
                sr.Write("some text in a new text file!")
                sr.Close()
        End Select
    End Sub
 
Back
Top