Archived Forum PostQuestion:
Hi,
I am working on an application where I use SFTP and for uploading I am using the WriteFileBytes function as I am working with streams.
I need to be able to upload files where the path does not always exists and even though that I adds createTruncate as createDisposition it fails with an error that the file does not exist.
My guess is that it is becourse the path does not exist.
So my question is:
What would be the best approach to handle this.
Should I always call the CreateDir function first even that the path exist or how should I handle it?
Thanks,
Hendrik
Example of an error text:
ChilkatLog:
OpenFile:
DllDate: Aug 28 2012
UnlockPrefix: HNDJNSSSH
Username: HENDRIK-PC:Hendrik
Architecture: Little Endian; 64-bit
Language: .NET 4.5 / x64
VerboseLogging: 0
SshVersion: SSH-2.0-OpenSSH_4.3
SftpVersion: 3
filename: store/ariel/events/records/2013/1/1/0/events~27_0~c2c36bac4991454f~9c23d7f2b57f8bd1~0
access: writeOnly
createDisposition: createTruncate
v3Flags: 0x1a
Sent FXP_OPEN
StatusResponseFromServer:
Request: FXP_OPEN
InformationReceivedFromServer:
StatusCode: 2
StatusMessage: No such file
--InformationReceivedFromServer
--StatusResponseFromServer
retryFilepath: ./store/ariel/events/records/2013/1/1/0/events~27_0~c2c36bac4991454f~9c23d7f2b57f8bd1~0
filename: ./store/ariel/events/records/2013/1/1/0/events~27_0~c2c36bac4991454f~9c23d7f2b57f8bd1~0
access: writeOnly
createDisposition: createTruncate
v3Flags: 0x1a
Sent FXP_OPEN
StatusResponseFromServer:
Request: FXP_OPEN
InformationReceivedFromServer:
StatusCode: 2
StatusMessage: No such file
--InformationReceivedFromServer
--StatusResponseFromServer
Failed.
--OpenFile
--ChilkatLog
Yes, the SSH/SFTP server is not automatically creating the directories that might not exist in the path. Your app would need to explicitly do it.