0 votes
by (350 points)

Been at this for two days...

My appication sends folders and files to a server with upload. On the computer, the path is as follows:


The folder 45 varies. That value comes from a label on my main form called lblID. Whatever value is in lblID is the name of the folder created on my PC. The structure goes like this on my local PC:

.../45 .../45/2010 .../45/2011 .../45/2012

SO basically, inside the folder "45" are folders with years, and inside the years are text files. And these folders/files get uploaded to the server.

The code to UPLOAD works A-ok, with no issues whatsoever. Here is the code:

client.PutFiles(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\Files\" & "" & lblID.Text & "*",
                        FtpBatchTransferOptions.Recursive, FtpActionOnExistingFiles.OverwriteDifferentSize)


On the server, it goes like this:


Then .../45 .../45/2010 .../45/2011 .../45/2012

Inside the 45 folder (remember, this value changes based on the lblID.text in the frmMain) are the years I uploaded.


Downloading these files back to the PC is making me pull my hair out.

Here is the code I have:

    client.GetFiles(String.Format("/files/backuplogfiles/{0}/*", lblID.Text),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "\DailyLog\Files\"),
FtpBatchTransferOptions.Recursive, FtpActionOnExistingFiles.OverwriteAll)

I just want to take that whole folder called 45 (or lblID.Text) and put it back in the local PC where it belongs...

I'm getting the error- Could not find target directory ('DailyLogFiles'). But I have that in the path.

Can someone take a look at this for me?

2 Answers

+1 vote
by (350 points)


It was a problem with my path.

The correct path I needed is

Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\Files\"),

And to refine it even further, I had the path wrong- this was the path I needed:

Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\Files\" & "" & lblID.Text & ""),

I had forgot the & in there. If I could delete this question I would. But it's here. Maybe it will jog someone else's memory.

0 votes
by (70.5k points)

The problem is caused by the Path.Combine method. Please note the method documentation:

public static string Combine(string path1, string path2)
If path2 contains an absolute path, this method returns path2.

To fix the problem change the second argument to relative path as follows: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DailyLog\Files\")

I suggest you to write the code as follows:

                    "DailyLog\Files\" & lblID.Text),

client.GetFiles("/files/backuplogfiles/" & lblID.Text,