FTP Download through C# - Illegal characters in path.

Discussion in 'Tech' started by Bran-Damage, Feb 10, 2009.

  1. Bran-Damage

    Bran-Damage New Member

    Messages:
    47
    Trophy Points:
    0
    Location:
    wisconsin
    This is the error I am getting - Illegal characters in path.

    This is driving me f@cking Nuts....

    I am working in c# and I am trying to upload a file to an FTP site, and download the file from the FTP site. There is no problems with permissions. I can manually copy and remove files from the ftp directories. I can also assure you that the path is correct.

    here is the code:

    private void OnElapsedTime(Object source, ElapsedEventArgs e)
    {
    try
    {
    timer.Enabled = false;
    //check for new files to download, run once for each carrier
    for (int x = 0; x < ftpSettings.Length; x++)
    {
    // added by smr 13nov07
    log.Write("DOWNLOAD FTDDownloadDirectory : " + ftpSettings[x].FTPDownloadDirectory, 1, false);
    log.Write("DOWNLOAD Username : " + ftpSettings[x].Username, 1, false);
    log.Write("DOWNLOAD Password : " + ftpSettings[x].Password, 1, false);
    log.Write("DOWNLOAD DownloadDirectory : " + ftpSettings[x].DownloadDirectory, 1, false);

    FTPclient down = new FTPclient(ftpSettings[x].FTPDownloadDirectory, ftpSettings[x].Username, ftpSettings[x].Password);
    down.DownloadDirectory(ftpSettings[x].DownloadDirectory, ftpSettings[x].FTPDownloadDirectory);


    }
    }
    catch (InvalidOperationException ex)
    {
    log.Write("UPLOAD ERROR: " + ex.Message, 1, false);

    }
    catch (Exception ex)
    {
    log.Write("DOWNLOAD ERROR: " + ex.Message, 1, false);

    }
    finally
    {
    timer.Enabled = true;
    }
    }

    Here is my log file:
    02/09/2009 150221 -- Smartlinc FTP Service - DOWNLOAD FTDDownloadDirectory : ftp://69.74.237.**********
    02/09/2009 150221 -- Smartlinc FTP Service - DOWNLOAD Username : *******
    02/09/2009 150221 -- Smartlinc FTP Service - DOWNLOAD Password : *******
    02/09/2009 150221 -- Smartlinc FTP Service - DOWNLOAD DownloadDirectory : C:\FTP\Download
    02/09/2009 150222 -- Smartlinc FTP Service - DOWNLOAD ERROR: Illegal characters in path.


    When I do this at my site, I have NO problems. When I drop this in at the customer site, I get this damn Illegal characters in path error. Maybe someone here has had this error before and knows what to do. Also, keep in mind, the file I am downloading, the names of the FTP directories, everything I have kept the same from my FTP download to their FTP download. The only difference is it is a different IP address.
  2. shahmrdi

    shahmrdi New Member

    Messages:
    1
    Trophy Points:
    0
    Illegar character in Path

    I am experincing the same problem . it works fine at my site but it does not at 2 spots .
    I would be pleased if anybody knows gives us advise .

    thanks
    Farshad
  3. Bran-Damage

    Bran-Damage New Member

    Messages:
    47
    Trophy Points:
    0
    Location:
    wisconsin
    I actually figured this out. Farshad, is the FTP server that you are trying to download from on a UNIX box? It seems as tough at the end of the path, i was getting a carriage return.