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?

asked 04 Aug '11, 17:17

Rob%20T's gravatar image

Rob T
422
accept rate: 33%

edited 05 Aug '11, 10:20

Martin%20Vobr's gravatar image

Martin Vobr ♦♦
335310


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.

link

answered 04 Aug '11, 17:44

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117
accept rate: 28%

edited 04 Aug '11, 17:46

Awesome, thanks a ton. Works perfectly.

(05 Aug '11, 06:20) Rob T
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×152
×5

Asked: 04 Aug '11, 17:17

Seen: 446 times

Last updated: 05 Aug '11, 10:20