如何使用更改FTP服务器上的目录权限的FtpWebRequest / WebRequest的(C#)?
How to change directory permissions on FTP server using FtpWebRequest/WebRequest (C#)?
我想这一点,但都没有成功(FTP不支持的方法除外):
I've tried this, but without success (ftp unsupported method exception):
ftpPath = ftpPath.Replace(dirname, "");
var request = (FtpWebRequest)WebRequest.Create(ftpPath);
request.Credentials = new NetworkCredential(config.FtpUser, config.FtpPassword);
request.UsePassive = true;
request.UseBinary = true;
request.Method = "CHMOD 777 " + dirname;
using (var resp = (FtpWebResponse)request.GetResponse())
任何其他建议?
Any other suggestions?
我发现这样做是使用psftp.exe和批处理命令的最简单方法。 参考: http://en.wikipedia.org/wiki/PuTTY
The simplest way I found to do this was to use psftp.exe and batch the command. Reference: http://en.wikipedia.org/wiki/PuTTY
我从System.Diagnostics.Process.Start()衍生PSFTP喂养它处理启动信息。 ......而写的命令到一个文本文件,里面装的过程参数引用 这不是一帆风顺的,我想它是,但它确实的伎俩。
I spawned psftp from System.Diagnostics.Process.Start() feeding it process start info. ...and wrote the commands into a text file that was referenced inside the process arguments It wasn't as smooth as I wanted it to be, but it did the trick.
我也看到了(但不使用)嵌入在从SSH文库的例子chmod命令: http://www.tamirgal.com/blog/page/SharpSSH.aspx
I have also seen (but not used) the chmod command embedded in the examples from the SSH library from: http://www.tamirgal.com/blog/page/SharpSSH.aspx
-TH