FTPWebRequest File.ReadOpen Could Not Find File

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
 
B

bruce barker

the ftp site requires credentials to open the file. to pass credentials
to another server you need a primary security token. if the browser is
local, you have one, else you have an impersonation token, which cannot
be used for network access.

options:

1) have asp.net use a domain / account instead of impersonation.
2) use basic authenication (givers server a primary token)
3) use kerberos authenication with forwarding enabled

-- bruce (sqlwork.com)
 
J

jlacefie

Bruce,

Thanks for the reply. Is it possible to implement your suggestions
for authentication with a Forms Authentication site? Currently I am
using Forms Authentication.

Thanks,

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top