how do i write to a text file over a network

JKVSP

New member
Joined
Mar 5, 2004
Messages
2
I have written to a text file on my local drive. now i want to write to a file on the network . eg. P:/ which is mapped to another server.
How do i write to the file there?

Thanks.

Code:
Dim FileName As String = Server.MapPath("p:\orderentry\orderno.txt")

Dim objStreamWriter As StreamWriter
objStreamWriter = File.CreateText(FileName)
objStreamWriter.WriteLine(intOrderID & "," & DateTime.Now.ToString)
objStreamWriter.Close()
 
JKVSP said:
I have written to a text file on my local drive. now i want to write to a file on the network . eg. P:/ which is mapped to another server.
How do i write to the file there?

Thanks.

Code:
Dim FileName As String = Server.MapPath("p:\orderentry\orderno.txt")

Dim objStreamWriter As StreamWriter
objStreamWriter = File.CreateText(FileName)
objStreamWriter.WriteLine(intOrderID & "," & DateTime.Now.ToString)
objStreamWriter.Close()

That code should work. dont forget to call Flush before Close though. Its good practice when using streams.
 
HJB417 said:
That code should work. dont forget to call Flush before Close though. Its good practice when using streams.

nope it doesnt work. gives me "Login failed. bad username..." error message is shown.

the text file has permission set for "Everyone"
 
Sounds like you havent been authenticated by the server, make sure you connect using the right username and password.
 
Dim FileName As String = Server.MapPath("p:\orderentry\orderno.txt")

dont know if its the same in VB than C# but in C# its more like this

string FileName = Server.MapPath(@"p:\orderentry\orderno.txt");
 
Back
Top