다음 스크립트를 사용하여 FTP를 통해 파일을 업로드하려고합니다. 파일은 FTP 서버로 업로드되지만 파일 이름은 항상 이미지라고하며 예외가 없습니다.FTP 파일 업로드 문제 - 누락 된 파일 이름
아마도 내가 놓친 간단한 것이지만 누군가가 도움이 될 수있는 잘못된 부분을 알고 있다면.
public static string _FTPusername = "xx";
public static string _FTPPassword = "xxxxx";
public static string _FTPServerAddress = "cp.domainname.co.uk";
public static string _ftpurl = "ftp://cp.domainname.co.uk/Images"; //= "ftp://cp.domainname.co.uk/Images";
try
{
string filename = Path.GetFileName(source);
string ftpfullpath = ConnectionDetails._ftpurl;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential(ConnectionDetails._FTPusername, ConnectionDetails._FTPPassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(source);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
}
catch(Exception ex)
{
throw ex;
}
난 당신이 어디서든 파일 이름 변수를 사용하여 표시되지 않는 이유는 무엇입니까? –