使用FTPClient for .NET 2.0。
我正在连接到vsftpd服务器,我能够编写文件,但无法运行命令。我提供了下面的代码。
当我使用命令提示符登录到ftp服务器时,我还可以运行报价站点chmod命令。我得到了200个站点CHMOD的命令好了。
这是服务器上的配置设置吗?
ftpClient.Connect();
string ftpLoc = folder + fileName;
using (var fileStream = File.OpenRead(localFile))
using (Stream ostream = ftpClient.OpenWrite(ftpLoc))
{
try
{
var buffer = new byte[8 * 1024];
int count;
while ((count = fileStream.Read(buffer, 0, buffer.Length)) > 0)
{
ostream.Write(buffer, 0, count);
}
FtpReply reply;
if (!(reply = ftpClient.Execute("SITE chmod 775 " + fileName)).Success)
{
throw new FtpCommandException(reply);
}
}
catch (Exception e)
{
logSW.WriteLine("ftp error: " + e.InnerException + " | " + e.Message);
return e.Message;
}
}发布于 2014-08-14 13:31:18
https://stackoverflow.com/questions/25308977
复制相似问题