Я пытаюсь загрузить изображения на FTP. Мне нужно, чтобы он был в сжатой папке с конкретным именем, а затем загрузить эту папку в определенный каталог. Каждый раз, когда я пытаюсь получить сообщение об ошибке, удаленный сервер возвращает ошибку: (550) файл недоступен
Этот код работает нормально, когда я пытаюсь загрузить одно изображение за раз. Здесь я пытаюсь загрузить целую папку. Я проверил URI (я скопировал его из отладки), и он пошел туда просто отлично. Есть ли другой способ загрузки папок? Я думал, что это проблема с правами на запись, но я могу вручную войти и загрузить папку в нужное место. Затем я попытался получить список каталогов, который я могу. Я также не могу загрузить папку в корень. Я довольно отчаянно! Я даже не знаю, где Google!
string ftpPassword = ConfigurationManager.AppSettings["ftpPassword"].ToString();
string uri = remoteDirectory;
FileInfo fileInf = new FileInfo(FileToUpload);
// Create FtpWebRequest object from the Uri provided
FtpWebRequest reqFTP = null;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
reqFTP.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
// Specify the data transfer type.
reqFTP.UseBinary = true;
// Notify the server about the size of the uploaded file
reqFTP.ContentLength = fileInf.Length;
// The buffer size is set to 2kb
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
// open file to be uploaded
using (FileStream fs = fileInf.OpenRead())
{
try
{
// Stream to which the file to be upload is written
using (Stream strm = reqFTP.GetRequestStream())
{
// Read from the file stream 2kb at a time till Stream content ends
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
// Write Content from the file stream to the FTP Upload Stream
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
}
reqFTP = null;
////Update the database with the new image location and delete the img from the uploadedimages folder
//DataAccess.UpdateImageDB(item.ProductID, item.ImgFolder + "/" + item.IMG);
System.IO.File.Delete(fileInf.ToString());
}
{
Console.WriteLine(ex.Message, "Upload Error");
}