Re: Exception with GetFiles() with Remove on Directory
This bug has been added to the tracker:
https://winscp.net/tracker/1299
https://winscp.net/tracker/1299
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Thanks. I have responded to your email.
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
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.
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
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, setSession.SessionLogPath
andSession.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?
$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()
Exception calling "Open" with "1" argument(s): "Error occurred during logging. It's been turned off."
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
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.$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)
Exception calling "GetFiles" with "3" argument(s): "Operation is not valid due to the current state of the object."
(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