Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WinSCP SFTP-.tmp进程无法访问该文件_C#_Sftp_Winscp_Winscp Net - Fatal编程技术网

C# WinSCP SFTP-.tmp进程无法访问该文件

C# WinSCP SFTP-.tmp进程无法访问该文件,c#,sftp,winscp,winscp-net,C#,Sftp,Winscp,Winscp Net,我试图上传文件使用以下代码,但下面得到错误 注意:我正在使用Windows7。使用CrushFTP SFTP服务器,可以使用FileZilla和WinSCP客户端连接,但通过代码这是一场噩梦 错误/异常: 中发生了类型为“System.IO.IOException”的第一次意外异常 mscorlib.dll 其他信息:进程无法访问该文件 “C:\Users\xxxxxxx\AppData\Local\Temp\wscp0D64.036B20B7.tmp”,因为 正在被另一个进程使用 我的连接代码

我试图上传文件使用以下代码,但下面得到错误

注意:我正在使用Windows7。使用CrushFTP SFTP服务器,可以使用FileZilla和WinSCP客户端连接,但通过代码这是一场噩梦

错误/异常:

中发生了类型为“System.IO.IOException”的第一次意外异常 mscorlib.dll

其他信息:进程无法访问该文件 “C:\Users\xxxxxxx\AppData\Local\Temp\wscp0D64.036B20B7.tmp”,因为 正在被另一个进程使用

我的连接代码如下

SessionOptions sessionOptions = new SessionOptions 
{ 
    Protocol = Protocol.Sftp, 
    HostName = "127.0.0.1", //hostname e.g. IP: 192.54.23.32, or mysftpsite.com 
    UserName = "xxxxxx", 
    Password = "yyyyyy", 
    PortNumber = zzzzz, //some number 
    SshHostKeyFingerprint = "ssh-rsa 1024 ::::04:85:3b:7a::::::::" 
}; 

using (Session session = new Session()) 
{ 
    session.Open(sessionOptions); //Attempts to connect to your sFtp site 
    //Get Ftp File 
    TransferOptions transferOptions = new TransferOptions(); 
    transferOptions.TransferMode = TransferMode.Binary; //The Transfer Mode - 
    // Automatic, Binary, or Ascii 
    transferOptions.FilePermissions = null; //Permissions applied to remote files; 
    //null for default permissions. Can set user, 
    //Group, or other Read/Write/Execute permissions. 
    transferOptions.PreserveTimestamp = false; //Set last write time of 
    //destination file to that of source file - basically change the timestamp 
    //to match destination and source files. 
    transferOptions.ResumeSupport.State = TransferResumeSupportState.Off; 

    TransferOperationResult transferResult; 
    //the parameter list is: local Path, Remote Path, Delete source file?, transfer Options 
    transferResult = session.PutFiles(@"C:\Adnan\a.txt", "/", false, transferOptions); 
    //Throw on any error 
    transferResult.Check(); 
    //Log information and break out if necessary 
}

我也遇到了这个例外。对我来说,它是在调用
session.Open(…)
时生成的


但是,这是WinSCP程序集生成并捕获的内部异常。我之所以注意到它,是因为我已将VisualStudio配置为在抛出每个异常时停止。如果我关闭此设置(或继续通过此设置和一些额外的内部IOException),SFTP连接将正确打开。

是否可以包括调用堆栈或调试日志()?调试日志。。最后几行。2015-01-20 09:52:26.317 -------------------------------------------------------------------------- . 2015-01-20 09:52:26.317正在查找主机“127.0.0.11”。2015-01-20 09:52:26.317连接到127.0.0.11端口54545。2015-01-20 09:52:27.318无法连接到127.0.0.11:网络错误:连接被拒绝。2015-01-20 09:52:27.318使用非标准协议或端口、隧道或代理将不会破坏FTP端口。这不是调试日志。这是会话日志(
session.SessionLogPath
)。你好,穆罕默德。你有没有想过这里有什么问题。我也有同样的困难。。。