Trouble Writing File

barski

Well-known member
Joined
Apr 7, 2002
Messages
239
Location
Tennessee
Ive working on creating export files with minimal success. I wrote a really simple routine and I keep getting an access to path is denied

Dim flwriter As StreamWriter
Dim i As Long

flwriter = File.CreateText("c:\jmyfile.txt")
For i = 1 To 10
flwriter.WriteLine(i)

Next i
flwriter.Close()

Any help would be appreciated
 
To use the streamwriter you first need to create a new instance of it before writing to.

where you declare the streamwriter replace with this

Code:
Dim flwriter As New IO.StreamWriter("c:\jmyfile.txt")

and remove line 3 flwriter = File.CreateText("c:\jmyfile.txt")

Now it should work

Andy
 
Back
Top