Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FTP from .net app
Message
From
25/03/2010 11:44:08
 
 
To
25/03/2010 09:25:34
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01457140
Message ID:
01457183
Views:
70
See if this helps:
FtpWebRequest UploadFtp;
UploadFtp = (FtpWebRequest)FtpWebRequest.Create(new System.Uri(FileName));  //address of ftp server/file
UploadFtp.Method = WebRequestMethods.Ftp.UploadFile;  //what we intend to do
UploadFtp.UseBinary = false;  //text (ascii) file
UploadFtp.Credentials = new NetworkCredential(LoginName,Password);  //authenticate to ftp server
UploadFtp.Proxy = null;
StreamReader UpStream = new StreamReader(LocalFileToUpload);  //stream to read saved file
byte[] UpStreamFileContents = System.Text.Encoding.UTF8.GetBytes(UpStream.ReadToEnd());  //byte array to hold file contents
UpStream.Close();  //close the stream
UploadFtp.ContentLength = UpStreamFileContents.Length;  //tell ftp server to expect this length

Stream UpStreamRequest = UploadFtp.GetRequestStream();  //new stream to send to ftp
UpStreamRequest.Write(UpStreamFileContents, 0, UpStreamFileContents.Length);  //write to ftp
UpStreamRequest.Close();  //close the stream

FtpWebResponse UpStreamResponse = (FtpWebResponse)UploadFtp.GetResponse();  //get the response from ftp
UpStreamResponse.Close();  //close the response stream
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform