Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FTP from .net app
Message
De
25/03/2010 11:44:08
 
 
À
25/03/2010 09:25:34
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01457140
Message ID:
01457183
Vues:
71
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform