J
jlacefie
Hello,
I am having trouble with the following code using ASP.Net 2.0. I
recieve an error on the line File.OpenRead(fPath) stating could not
find file . The fPath comes from a textbox control on the client and
the error displays the correct path for the file. This code works
when I use the browser on the server that is hosting the site, but it
does not work when I access this site on any other machine. Does the
OpenRead only work on local "server" files? I appreciated any help!
'Create a FTP Request Object and Specfiy a Complete Path
Dim reqObj As FtpWebRequest = WebRequest.Create(server & "/" &
filename)
'Call A FileUpload Method of FTP Request Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile
'If you want to access Resourse Protected You need to give
User Name and PWD
reqObj.Credentials = New NetworkCredential(user, password)
'FileStream object read file from Local Drive
Dim streamObj As FileStream = File.OpenRead(fPath)
'Store File in Buffer
Dim buffer(streamObj.Length) As Byte
'Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length)
'Close FileStream Object Set its Value to nothing
streamObj.Close()
streamObj = Nothing
'Upload File to ftp://localHost/ set its object to nothing
'reqObj.GetRequestStream().Write(buffer, 0, buffer.Length)
reqObj.GetRequestStream.Write(buffer, 0, buffer.Length)
reqObj = Nothing
I am having trouble with the following code using ASP.Net 2.0. I
recieve an error on the line File.OpenRead(fPath) stating could not
find file . The fPath comes from a textbox control on the client and
the error displays the correct path for the file. This code works
when I use the browser on the server that is hosting the site, but it
does not work when I access this site on any other machine. Does the
OpenRead only work on local "server" files? I appreciated any help!
'Create a FTP Request Object and Specfiy a Complete Path
Dim reqObj As FtpWebRequest = WebRequest.Create(server & "/" &
filename)
'Call A FileUpload Method of FTP Request Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile
'If you want to access Resourse Protected You need to give
User Name and PWD
reqObj.Credentials = New NetworkCredential(user, password)
'FileStream object read file from Local Drive
Dim streamObj As FileStream = File.OpenRead(fPath)
'Store File in Buffer
Dim buffer(streamObj.Length) As Byte
'Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length)
'Close FileStream Object Set its Value to nothing
streamObj.Close()
streamObj = Nothing
'Upload File to ftp://localHost/ set its object to nothing
'reqObj.GetRequestStream().Write(buffer, 0, buffer.Length)
reqObj.GetRequestStream.Write(buffer, 0, buffer.Length)
reqObj = Nothing