Re: Working session.CreateDirectory example for VB.NET/VBA
Update: Figured out the issue. I had misunderstood how to reference the remote path. Now when I use
mySession.CreateDirectory("example.com/test2")
it works fine.
Btw, thanks for a cool piece of software with a working API
---
Thanks for your response.
I did try using
mySession.CreateDirectory("/test2") i.e. without the slash as well.
I feel like I am missing something really simple here so maybe a specific example would be easier.
Let's say my domain is
"www.example.com"
and I want to add the directory
"test2"
The code:
Dim mySession As New Session
Dim mySessionOptions As New SessionOptions
With mySessionOptions
.Protocol = Protocol_Ftp
.HostName = "example.com"
.UserName = "user"
.Password = "password"
End With
mySession.Open mySessionOptions
'Until this point the code works fine.
mySession.CreateDirectory ("/test2") 'DOES NOT WORK
mySession.CreateDirectory ("/test2/") 'DOES NOT WORK
mySession.CreateDirectory ("test2") 'DOES NOT WORK
mySession.CreateDirectory ("test2/") 'DOES NOT WORK
What code do I need to add to create the directory "test2" for domain "www.example.com"?
mySession.CreateDirectory("example.com/test2")
it works fine.
Btw, thanks for a cool piece of software with a working API
---
Thanks for your response.
I did try using
mySession.CreateDirectory("/test2") i.e. without the slash as well.
I feel like I am missing something really simple here so maybe a specific example would be easier.
Let's say my domain is
"www.example.com"
and I want to add the directory
"test2"
The code:
Dim mySession As New Session
Dim mySessionOptions As New SessionOptions
With mySessionOptions
.Protocol = Protocol_Ftp
.HostName = "example.com"
.UserName = "user"
.Password = "password"
End With
mySession.Open mySessionOptions
'Until this point the code works fine.
mySession.CreateDirectory ("/test2") 'DOES NOT WORK
mySession.CreateDirectory ("/test2/") 'DOES NOT WORK
mySession.CreateDirectory ("test2") 'DOES NOT WORK
mySession.CreateDirectory ("test2/") 'DOES NOT WORK
What code do I need to add to create the directory "test2" for domain "www.example.com"?
How to exactly specify the path. My relative path "/test/" works fine when uploading a file but fails when using
Set newDir = mySession.CreateDirectory("/test2/")
Try just "/test" (no trailing slash).
(Btw, the "/test/" seems like an absolute path to me).
How can I implement error checking and confirmation similar to how it is done for uploads?
TheSession.CreateDirectory
throw an exception on any error.
See https://winscp.net/eng/docs/library_session_createdirectory#exceptions