0

When I open a request to a server it opens to a default directory (user directory).

I want to get a file that is in a completely different path.

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + txtHost.Text);
            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
            request.Credentials = new NetworkCredential("xxxx", "yyyy");
            request.UseBinary = true;
            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

Now the request points to
'\user\ssfactor'
and I want a file in
'\factor\dktest\pdi'

Is this possible?

If not, can someone offer me another programmatic way? I tried Ssh.Net, but it only seems to work on ssh servers.

Belmiris
  • 2,741
  • 3
  • 25
  • 29
  • 1
    Sure, just add `/%2E%2E` (one directory) `/%2E%2E/%2E%2E` (two back) as part of the request (if I understand you) correctly. – Trevor May 17 '19 at 19:38
  • 1
    This totally depends on how the FTP server at the other end is configured. And frankly, if the FTP is configured to allow you to navigate up a directory it is probably configured incorrectly. – iakobski May 17 '19 at 19:55
  • Çöđěxěŕ - I tried the path 'ftp://10.0.0.4/%2E%2E/%2E%2E/factor/dktest/pdi" which should take it to the path but got a (550) File unavailable error. – Belmiris May 17 '19 at 20:01
  • iakobski - You are probably right. It seems like the whole server is pretty much open to ftp. It's why I am having trouble, all the internet examples seem to assume there is only one 'ftp path'. – Belmiris May 17 '19 at 20:03
  • I typed FTP into the nuget browser and a couple options came up (probably should have done that initially). I installed FluentFTP and it seems to do the trick: https://stackoverflow.com/questions/41460069/download-files-using-fluentftp – Belmiris May 17 '19 at 20:05

0 Answers0