我有允许我访问服务器以执行ftp事务的代码。我已经测试了连接并且工作正常。问题是保存文件。帮助画一幅画,这是地址的设置方式。保存子目录中的ftp服务器上的文件
FTP服务器: ftp.MyMainDomain.com
路径登录FTP点: www.another_website_Under_myDomain.com/gallery/images
,当我直接测试连接,FTP服务器图钉我图像文件夹,我甚至读过子目录(ie ..images/subdirectory1, ..images/subdirectory2)。
我现在需要它能够将文件保存到每个文件夹中。我认为我所要做的只是添加subdir,我想访问ftp_server uri的结尾,但这不起作用。我该怎么办?
Uri ftpUri = new Uri((Ftp_Server_Address + "/" + SubDirectory+ "/"), UriKind.Absolute);
if (ftpUri.Scheme == Uri.UriSchemeFtp)// check ftp address,
{
DirRequest = (FtpWebRequest)FtpWebRequest.Create(ftpUri);
DirRequest.Method = ReqMethod;
DirRequest.Credentials = new NetworkCredential(FtpUserName, FtpPassword);
DirRequest.UsePassive = true;
DirRequest.UseBinary = true;
DirRequest.KeepAlive = false;
//change picture to stream
Stream PicAsStream = Pic.Bitmap_to_Stream(Pic.BitmapImage_to_Bitmap(Pic.Photo));
//send ftp with picture
Stream ftpReqStream = DirRequest.GetRequestStream();
ftpReqStream = PicAsStream;
ftpReqStream.Close();
SendFtpRequest(ReqMethod);
}
2013-07-19
chris
+0
“不起作用”是什么意思?这并不能说明有关问题的任何信息。 –
+0
如上所述“我现在需要它能够将文件保存到每个文件夹中......” –
+0
那么,你的代码做什么,你不指望?或者你没有期望做什么?你有错误吗?如果是这样,什么和在哪里?它是否保存文件? –