次のスクリプトを使用してFTP経由でファイルをアップロードしようとしています。ファイルはFTPサーバーにアップロードされますが、ファイル名は常にImagesと呼ばれ、exenchionはありません。FTPファイルのアップロードに関する問題 - ファイル名がありません
おそらく何か私は逃しましたが、誰かが助けになる間違っていることを知っていればそれは分かりません。あなたはファイル名の変数を使用していないので、中に渡されるパスが
ftp://cp.domainname.co.uk/Images
ある
string filename = Path.GetFileName(source);
string ftpfullpath = ConnectionDetails._ftpurl;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
:
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;
}
は、私はあなたがどこでもあなたのファイル名の変数を使用して表示されないのですか? –