Я пытаюсь загрузить файл в папку FTP, но получаю следующую ошибку.Загрузка файлов в папку ftp со специальными символами в имени
The remote server returned an error: (550) File unavailable (e.g., file not found, no access)
Я использую следующий образец, чтобы проверить это:
// Get the object used to communicate with the server.
string path = HttpUtility.UrlEncode("ftp://host:port//01-03-2017/John, Doe S. M.D/file.wav");
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(path);
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("user", "password");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(@"localpath\example.wav");
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
- Я могу загрузить файлы на родительской папке
01-03-2017
но не в целевой папкеROLLINS, SETH S. M.D
, которая явно имеет специальные символы Это. - Я могу загрузить файлы с помощью FileZilla
- Я пытался
HttpUtility.UrlEncode
, но это не помогло
Спасибо за ваше время и помощь.
Проблема с URL: используйте «//» после каждого имени папки вместо «/» @Ankit – Prabu