Я пытаюсь загрузить файл, используя следующий код, но получая ошибку ниже.WinSCP SFTP - .tmp Процесс не может получить доступ к файлу
Некоторые примечания. Я использую Windows 7. С помощью SFTP-сервера CrushFTP можно подключаться с использованием FileZilla и WinSCP-клиента, но через код это кошмар.
Ошибка/исключение:
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: The process cannot access the file 'C:\Users\xxxxxxx\AppData\Local\Temp\wscp0D64.036B20B7.tmp' because it is being used by another process.
Мой код для подключения ниже
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.DebugLogPath'] (http://winscp.net/eng/docs/library_session))? –
debug log .. последние несколько строк. 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'). –