无法使用 Sharpssh 重命名远程文件
我写了如下代码。 但此代码不可用...
当我执行时,会发生。 如果有人知道什么,请给我建议... 提前致谢。
void sftp_OnTransferEnd(string src, string dst, int transferredBytes
, int totalBytes, string message)
{
if (sftp == null)
{
sftp = new Sftp(Const.SFTP_HOST, Const.SFTP_USER, Const.SFTP_PASSWORD);
sftp.Connect();
}
SftpChannel.rename("file/123_Uploading.zip", "file/123_Finished.zip");
}
--------------------------------------------
Sftp.cs
public void Rename(string oldPath, string newPath)
{
SftpChannel.rename(oldPath, newPath);
}
---------------------------------------------
错误发生在以下地方...
---------------------------------------------------------
ChannelSftp.cs
public void rename(String oldpath, String newpath)
{
・
・
・
int i=buf.getInt(); << i == 4
if(i==SSH_FX_OK) return;
throwStatusError(buf, i); << throw error
catch(Exception e)
{
if(e is SftpException) throw (SftpException)e; << thrown error (id >> 4, message >> Failure)
throw new SftpException(SSH_FX_FAILURE, "");
}
}
i wrote like the following code.
but this code is not available...
when i execute, occur.
if anyone knows something, give me advice pls...
thanks in advance.
void sftp_OnTransferEnd(string src, string dst, int transferredBytes
, int totalBytes, string message)
{
if (sftp == null)
{
sftp = new Sftp(Const.SFTP_HOST, Const.SFTP_USER, Const.SFTP_PASSWORD);
sftp.Connect();
}
SftpChannel.rename("file/123_Uploading.zip", "file/123_Finished.zip");
}
--------------------------------------------
Sftp.cs
public void Rename(string oldPath, string newPath)
{
SftpChannel.rename(oldPath, newPath);
}
---------------------------------------------
Error occur the following place...
---------------------------------------------------------
ChannelSftp.cs
public void rename(String oldpath, String newpath)
{
・
・
・
int i=buf.getInt(); << i == 4
if(i==SSH_FX_OK) return;
throwStatusError(buf, i); << throw error
catch(Exception e)
{
if(e is SftpException) throw (SftpException)e; << thrown error (id >> 4, message >> Failure)
throw new SftpException(SSH_FX_FAILURE, "");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当前的 NuGet 包仍然是
1.1.1.13
版本,不包含Rename
方法。如果软件包维护者可以更新它,那就太好了。但与此同时,如果其他人需要使用当前的 NuGet 包,这里有一个基于反射的扩展方法解决方案。不太好,但至少我可以使用该包而无需分叉/重建等。
The current NuGet package is still of version
1.1.1.13
which does not contain theRename
method. It would be great if the package maintainer could update it.But in the meantime if anyone else needs it with the current NuGet package, here is a Reflection-based extension method solution. Not nice, but at least I can use the package without forking/rebuilding, etc.
我将您的
代码添加到 Sftp.cs 类中并调用它:
然后它成功重命名了我的文件。顺便说一句谢谢
I added your
code into Sftp.cs class and I called it :
then it renamed my file successfully.Thanks by the way