SFTP - Win7 - .tmp The process cannot access the file

Advertisement

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

SFTP - Win7 - .tmp The process cannot access the file

i m trying to upload file using following code but getting error below


some notes:

i m using windows 7. using crushFTP sftp server, able to connect with using filezilla and winscp client but through code its being nightmare


error/exception
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.


my code to connect is below

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 -
//<em style="font-size: 9pt;">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
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: SFTP - Win7 - .tmp The process cannot access the file

Please attach a full debug log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.DebugLogPath. Submit the log with your post as an attachment. If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

I have added the log file as private attachment.


martin wrote:

Please attach a full debug log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.DebugLogPath. Submit the log with your post as an attachment. If you do not want to post the log publicly, you can mark the attachment as private.
  • winscpSftp.log (3.58 KB, Private file)
Description: log file

Reply with quote

martin
Site Admin
martin avatar

Re: SFTP - Win7 - .tmp The process cannot access the file

Again, this is not a debug log. It's a session log. Please set also Session.DebugLogPath, not only Session.SessionLogPath. Please, attach both logs.

Reply with quote

Advertisement

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

Thanks for your response.

When I set DebugLogPath like below
session.DebugLogPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\debugwinscpSftp.log";

I get following exception
Additional information: The specified registry key does not exist.

martin wrote:

Again, this is not a debug log. It's a session log. Please set also Session.DebugLogPath, not only Session.SessionLogPath. Please, attach both logs.

Reply with quote

martin
Site Admin
martin avatar

Re: SFTP - Win7 - .tmp The process cannot access the file

Can you post complete information about the exception? (exception type, callstack, exception message)

Reply with quote

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

I have attached screenshot, please take a look. hope it helps

martin wrote:

Can you post complete information about the exception? (exception type, callstack, exception message)
  • winscp.png (115.13 KB, Private file)

Reply with quote

Advertisement

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

stack trace produced this only
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)


System.IO.IOException occurred
_HResult=2
_message=The specified registry key does not exist.
HResult=2
IsTransient=false
Message=The specified registry key does not exist.
Source=mscorlib
StackTrace:
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
InnerException:


martin wrote:

I need to see the "StackTrace".

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: SFTP - Win7 - .tmp The process cannot access the file

adnanaman wrote:

stack trace produced this only
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
I find this unlikely. Are you sure you expanded the "StackTrace" row on the table?

Anyway, can you try to split your code to:
string debugLogPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\debugwinscpSftp.log";
session.DebugLogPath = debugLogPath;
And check which line throws the exception?

Reply with quote

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

I have attached screenshot for you. I also tried by giving file name rather full path so it generates the file in output folder like session log file but still same response. If you want i can send you whole code (project)


martin wrote:

adnanaman wrote:

stack trace produced this only
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
I find this unlikely. Are you sure you expanded the "StackTrace" row on the table?

Anyway, can you try to split your code to:
string debugLogPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\debugwinscpSftp.log";
session.DebugLogPath = debugLogPath;
And check which line throws the exception?
  • winscp.png (129.28 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: SFTP - Win7 - .tmp The process cannot access the file

adnanaman wrote:

I have attached screenshot for you. I also tried by giving file name rather full path so it generates the file in output folder like session log file but still same response.
And did you click the drop down button on the right? See attached screenshot.

If you want i can send you whole code (project)
Well, you can try. But I believe it's something with your environment, rather than the code.

stacktrace.png

Reply with quote

Advertisement

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

When i expand there is no more detail its just one line..

so what could be wrong about environment? Firewall? How can i check


martin wrote:

adnanaman wrote:

I have attached screenshot for you. I also tried by giving file name rather full path so it generates the file in output folder like session log file but still same response.
And did you click the drop down button on the right? See attached screenshot.

If you want i can send you whole code (project)
Well, you can try. But I believe it's something with your environment, rather than the code.
  • winscp.png (105.79 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: SFTP - Win7 - .tmp The process cannot access the file

OK, that's strange.
Can you download a code of the .NET assembly and build your project against it? Maybe you get a stack trace then. And if not, you should be able to step into the DebugLogPath setter to see where it throws.
The code is part of overall source code package of WinSCP.

Not sure about what can be the problem with the environment.

Reply with quote

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

Please take a look on exception screenshot

martin wrote:

OK, that's strange.
Can you download a code of the .NET assembly and build your project against it? Maybe you get a stack trace then. And if not, you should be able to step into the DebugLogPath setter to see where it throws.
The code is part of overall source code package of WinSCP.

Not sure about what can be the problem with the environment.
  • debug location error.png (106.94 KB, Private file)
Description: PerformanceCounterCategory[] categories = PerformanceCounterCategory.GetCategories();

is throwing exception

Reply with quote

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

Hi

some how i manage to get debug log... can you please take a look


adnanaman wrote:

Please take a look on exception screenshot

martin wrote:

OK, that's strange.
Can you download a code of the .NET assembly and build your project against it? Maybe you get a stack trace then. And if not, you should be able to step into the DebugLogPath setter to see where it throws.
The code is part of overall source code package of WinSCP.

Not sure about what can be the problem with the environment.
  • debugwinscpSftp.log (37.28 KB, Private file)

Reply with quote

Advertisement

adnanaman
Joined:
Posts:
11
Location:
United Kingdom

Re: SFTP - Win7 - .tmp The process cannot access the file

I have attached code also and there are two functions one used winscp and other use other third party dll..

winscp is throwing exception but other is working for same server / credentials



adnanaman wrote:

Hi

some how i manage to get debug log... can you please take a look


adnanaman wrote:

Please take a look on exception screenshot

martin wrote:

OK, that's strange.
Can you download a code of the .NET assembly and build your project against it? Maybe you get a stack trace then. And if not, you should be able to step into the DebugLogPath setter to see where it throws.
The code is part of overall source code package of WinSCP.

Not sure about what can be the problem with the environment.
  • sftp code.txt (6.5 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: SFTP - Win7 - .tmp The process cannot access the file

OK, that's some progress!

What did you do to get the debug log?
The exception screenshot you posted is a "first chance" exception. It should be caught few lines later and should not make it to you code. Did you try to debug it further to see what happens next?

I have sent you an email with a debug version of WinSCP to address you have used to register on this forum.

Reply with quote

Advertisement

You can post new topics in this forum