我试图在我的ftp服务器上上传一个excel文件。我可以上传,但上传的文件无法打开。我也尝试上传照片。同样的问题。 文件似乎" 0字节"在ftp ..
这是我的代码;
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.ShowDialog();
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://labquiz.hostoi.com/public_html/dosyalar/" + openFileDialog.SafeFileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("a3026029", "*******");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = true;
FileStream stream = File.OpenRead(openFileDialog.InitialDirectory + openFileDialog.FileName);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
MessageBox.Show("Upload File Complete, Status: " + response.StatusDescription);
response.Close();