Topic "Exception with GetFiles() with Remove on Directory"

Author Message
dotps1

Guest


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:
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:
Quote:
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:
Quote:

(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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
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?
dotps1

Guest


here is my code:
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:
Quote:

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:
Quote:

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
dotps1

Guest


prikryl 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

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
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.
dotps1
[View user's profile]
Contributor
Joined: 2015-03-23
Posts: 15
Location: United States
prikryl 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.

Code:

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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Thanks. I have responded to your email.
_________________
Martin Prikryl
dotps1
[View user's profile]
Contributor
Joined: 2015-03-23
Posts: 15
Location: United States
prikryl 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:

Code:

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

Description: (none)

Debug.log (34.57 KB) Private file

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
This bug has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=1299
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License