23/04/10 6:52
marco444
l'ho provato, ma non mi sembra che faccia al caso mio, non posso metterci nome utente e pass, però ho trovato questo:
//get the contents of the file you want to upload
byte[] fileContents;
string FinalFile = @"c:\autoexec.bat";
using(System.IO.FileStream fs = new System.IO.FileStream(FinalFile, System.IO.FileMode.Open)) {
fileContents = new byte[fs.Length];
fs.Read(fileContents, 0, (int)fs.Length);
}
//get the filename, append it to the URL
System.IO.FileInfo fi = new System.IO.FileInfo(FinalFile);
//FTPServerURI must be in the format of:
//ftp.myserver.com/path/to/upload/folder/
string uri = string.Format("{0}{1}", FTPServerURI, fi.Name);
//now we have:
//ftp.myserver.com/path/to/upload/folder/…
//create the ftp request
System.Net.WebRequest request = System.Net.FtpWebRequest.Create(uri);
//state that we uploading the file
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
//get the request stream
using (System.IO.Stream stm = request.GetRequestStream()) {
//write the contents of the file up
stm.Write(zipContents, 0, zipContents.Length);
}
puo essere valido anche se è per c?
//get the contents of the file you want to upload
byte[] fileContents;
string FinalFile = @"c:\autoexec.bat";
using(System.IO.FileStream fs = new System.IO.FileStream(FinalFile, System.IO.FileMode.Open)) {
fileContents = new byte[fs.Length];
fs.Read(fileContents, 0, (int)fs.Length);
}
//get the filename, append it to the URL
System.IO.FileInfo fi = new System.IO.FileInfo(FinalFile);
//FTPServerURI must be in the format of:
//ftp.myserver.com/path/to/upload/folder/
string uri = string.Format("{0}{1}", FTPServerURI, fi.Name);
//now we have:
//ftp.myserver.com/path/to/upload/folder/…
//create the ftp request
System.Net.WebRequest request = System.Net.FtpWebRequest.Create(uri);
//state that we uploading the file
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
//get the request stream
using (System.IO.Stream stm = request.GetRequestStream()) {
//write the contents of the file up
stm.Write(zipContents, 0, zipContents.Length);
}
puo essere valido anche se è per c?
aaa