File System Object

  • Thread starter Thread starter Vicky S
  • Start date Start date
V

Vicky S

Hello,
I'm new to dot net and I can't seem to find the object name that is
equivalent to Scripting.FileSystemObject. Can anyone help?

Thanks,
V
 
Thanks,
I can now generate a file.. but for some reason, it's not writing to it..
what am I doing wrong?

Dim oFile As System.IO.File, oStream As System.IO.StreamWriter

Dim filename As String

filename = Application.ExecutablePath & "\..\importlog.txt"

oStream = oFile.CreateText(filename)

oStream.WriteLine(Now() & " " & strMessage)
 
In your example you just have to call the Close method of the stream object.

But, to do what you want, I'd consider a different approach:

Dim stream As System.IO.StreamWriter

Try

stream = New System.IO.StreamWriter("c:\temp\test.txt", True)

stream.Write("test")

Finally

If Not stream Is Nothing Then

stream.Close()

End If

End Try


Note that you can't forget to close the stream, even if an exception has
occured.
 
Back
Top