Exception with GetFiles() with Remove on Directory

Advertisement

dotps1
Guest

Exception with GetFiles() with Remove on Directory

Hello, this is my first issue i have come across with WinSCP, I am getting an error when i use the GetFiles() method and use the Remove Parameter and it is for a directory. It seems to work find when I get just a file.

Here is my set up:

WinSCP 5.7.0.0
Windows 8.1 x64 Enterprise
PowerShell V4
FileZilla FTP Server running locally.

Here is my Code:
$so = New-Object WinSCP.SessionOptions
$so.UserName = "MyUser"
$so.Password = "MyPassword"
$so.HostName = "127.0.0.1"
$so.Protocol = "Ftp"

$s = New-Object WinSCP.Session
$s.Open($so)

$s.GetFiles("./TestFolder", "C:\Local\TestFolder", $true)

And it is throwing the following error:
Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object."

But, it is actually transfering the folder, and removing it from the source. And here is the FileZilla info, with no errors:
(000120)3/20/2015 9:56:29 AM - myuser (127.0.0.1)> PWD
(000120)3/20/2015 9:56:29 AM - myuser (127.0.0.1)> 257 "/" is current directory.
(000120)3/20/2015 9:56:59 AM - myuser (127.0.0.1)> REST 0
(000120)3/20/2015 9:56:59 AM - myuser (127.0.0.1)> 350 Rest supported. Restarting at 0
(000120)3/20/2015 9:57:29 AM - myuser (127.0.0.1)> REST 0
(000120)3/20/2015 9:57:29 AM - myuser (127.0.0.1)> 350 Rest supported. Restarting at 0
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> MLST /TestFolder
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 250-Listing /TestFolder
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> type=dir;modify=20150320135457; /TestFolder
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 250 End
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> CWD /TestFolder/
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 250 CWD successful. "/TestFolder" is current directory.
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> PWD
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 257 "/TestFolder" is current directory.
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> TYPE A
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 200 Type set to A
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> PASV
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 227 Entering Passive Mode (127,0,0,1,223,251)
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> MLSD
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 150 Opening data channel for directory listing of "/TestFolder"
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 226 Successfully transferred "/TestFolder"
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> CWD /
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 250 CWD successful. "/" is current directory.
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> RMD /TestFolder/
(000120)3/20/2015 9:57:40 AM - myuser (127.0.0.1)> 250 Directory deleted successfully


Thanks for any help.

Reply with quote

Advertisement

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

Re: Exception with GetFiles() with Remove on Directory

Thanks for your report.

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

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

Also, can you see a callstack of the exception?

Reply with quote

dotps1
Guest

Cannot get logs to run

here is my code:
$so = New-Object WinSCP.SessionOptions
$so.UserName = "MyUser"
$so.Password = "MyPassword"
$so.HostName = "127.0.0.1"
$so.Protocol = "Ftp"

$s = New-Object WinSCP.Session

$s.DebugLogPath = "C:\Local"
$s.SessionLogPath = "C:\Local"
$s.Open($so)

$s.GetFiles("./TestFolder", "C:\Local\TestFolder", $true)

$s.Close()

i get access denied message for the debug log. I tried a few differnt locations, and i gave everyone full control to the path in the code. If i comment that out and only try to use the sessionlog, i get this:
Exception calling "Open" with "1" argument(s): "Error occurred during logging. It's been turned off."

i will keep trying to get that to work.


here is the full error i get for the GetFiles() exception:
Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current
state of the object."
At line:12 char:1
+ $s.GetFiles("./TestFolder", "C:\Local\TestFolder", $true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException

Reply with quote

dotps1
Guest

Re: Exception with GetFiles() with Remove on Directory

martin wrote:

Thanks for your report.

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

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

Also, can you see a callstack of the exception?

Sorry, i didn't know you had to actually specify a file name for the log(s). So here they are.

Thanks again.
  • session.log (6.49 KB, Private file)
Description: session log
  • debug.log (34.58 KB, Private file)
Description: debug log

Reply with quote

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

Re: Exception with GetFiles() with Remove on Directory

Do you have a callstack of the exception?

Can you send me an email, so I can send you back a debug version of WinSCP to track the problem? Please include link back to this topic in your email. Also note in this topic that you have sent the email. Thanks.

You will find my address (if you log in) in my forum profile.

Reply with quote

Advertisement

dotps1
Contributor
Joined:
Posts:
20
Location:
United States

Re: Exception with GetFiles() with Remove on Directory

martin wrote:

Do you have a callstack of the exception?

Can you send me an email, so I can send you back a debug version of WinSCP to track the problem? Please include link back to this topic in your email. Also note in this topic that you have sent the email. Thanks.

You will find my address (if you log in) in my forum profile.

i used the Resolve-Error function to generate this stacktrace, hope it helps.

PSMessageDetails      : 
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object." ---> System.InvalidOperationException: Operation is not valid due to the current 
                        state of the object.
                           at WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)
                           at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
                           at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
                           at System.Management.Automation.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : InvalidOperationException
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}





MyCommand             : 
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 1
OffsetInLine          : 1
HistoryId             : -1
ScriptName            : 
Line                  : $s.GetFiles("./TestFolder", "C:\Local", $true)
PositionMessage       : At line:1 char:1
                        + $s.GetFiles("./TestFolder", "C:\Local", $true)
                        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot          : 
PSCommandPath         : 
InvocationName        : 
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition : 



00000000000000000000000000000000000000000000000000000000000000000000000000000000


ErrorRecord                 : Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object."
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                                 at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
                                 at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
                                 at System.Management.Automation.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
WasThrownFromThrowStatement : False
Message                     : Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object."
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              : System.InvalidOperationException: Operation is not valid due to the current state of the object.
                                 at WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)
                                 at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
TargetSite                  : Void ConvertToMethodInvocationException(System.Exception, System.Type, System.String, Int32, System.Reflection.MemberInfo)
HelpLink                    : 
Source                      : System.Management.Automation
HResult                     : -2146233087



11111111111111111111111111111111111111111111111111111111111111111111111111111111


Message        : Operation is not valid due to the current state of the object.
Data           : {}
InnerException : 
TargetSite     : WinSCP.TransferOperationResult GetFiles(System.String, System.String, Boolean, WinSCP.TransferOptions)
StackTrace     :    at WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)
                    at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
HelpLink       : 
Source         : WinSCPnet
HResult        : -2146233079

Reply with quote

dotps1
Contributor
Joined:
Posts:
20
Location:
United States

Re: Exception with GetFiles() with Remove on Directory

martin wrote:

Thanks. I have responded to your email.

Same exception with latest version. I have attached the Log(s) and here is the stack trace:

PSMessageDetails      : 
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object." ---> System.InvalidOperationException: Operation is not valid due to the current 
                        state of the object.
                           at WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)
                           at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
                           at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
                           at System.Management.Automation.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : InvalidOperationException
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 13
PipelineIterationInfo : {}





MyCommand             : 
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 13
OffsetInLine          : 1
HistoryId             : -1
ScriptName            : 
Line                  : $s.GetFiles("./TestFolder", "C:\Local\TestFolder", $true)
                        
PositionMessage       : At line:13 char:1
                        + $s.GetFiles("./TestFolder", "C:\Local\TestFolder", $true)
                        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot          : 
PSCommandPath         : 
InvocationName        : 
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition : 



00000000000000000000000000000000000000000000000000000000000000000000000000000000


ErrorRecord                 : Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object."
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                                 at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
                                 at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
                                 at System.Management.Automation.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
WasThrownFromThrowStatement : False
Message                     : Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object."
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              : System.InvalidOperationException: Operation is not valid due to the current state of the object.
                                 at WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)
                                 at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
TargetSite                  : Void ConvertToMethodInvocationException(System.Exception, System.Type, System.String, Int32, System.Reflection.MemberInfo)
HelpLink                    : 
Source                      : System.Management.Automation
HResult                     : -2146233087



11111111111111111111111111111111111111111111111111111111111111111111111111111111


Message        : Operation is not valid due to the current state of the object.
Data           : {}
InnerException : 
TargetSite     : WinSCP.TransferOperationResult GetFiles(System.String, System.String, Boolean, WinSCP.TransferOptions)
StackTrace     :    at WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)
                    at CallSite.Target(Closure , CallSite , Object , String , String , Boolean )
HelpLink       : 
Source         : WinSCPnet
HResult        : -2146233079
  • Session.log (7.05 KB, Private file)
  • Debug.log (34.57 KB, Private file)

Reply with quote

Advertisement

You can post new topics in this forum