0 votes
by (350 points)
edited

I can't seem to figure out this what seems simple command-

I can upload folders and files based on the value in a textbox (actually a label- same deal)

client.PutFiles(
   "C:\Program Files\DailyLog\Files\*", 
   "/files/logfiles/" & frmMain.lblID.Text & "", 
   FtpBatchTransferOptions.Recursive)

So if there's files in on the server already, and I need to add more or append whats already there, I can't because it says they already exist.

So I tried this based on a search I did-

client.GetUploadStream(
"C:\Program Files\DailyLog\Files\*", 
"/files/logfiles/" & frmMain.lblID.Text & "", 
FtpBatchTransferOptions.Recursive)

But because the value in the frmMain.lblID.Text is a number, I get the following error-

Conversion from string "/files/logfiles/1" to type 'Integer' is not valid. (with "1" being the number in the lblID.Text in my form.

I also tried client.RemoveDirectory("/files/logfiles/" & frmMain.lblID.Text & "")

So how can I solve this?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (72.7k points)
edited

To overwrite existing files on target destination, please specify the last parameter to FtpActionOnExistingFiles.OverwriteAll as follows:

client.PutFiles(
    "C:\Program Files\DailyLog\Files\*", 
    string.Format("/files/logfiles/{0}", frmMain.lblID.Text), 
    FtpBatchTransferOptions.Recursive,
    FtpActionOnExistingFiles.OverwriteAll)

Using the string.Format method instead of the & operator should fix the "Conversion from string..." error.

by (350 points)
edited

Awesome, thanks a ton. Works perfectly.

...