Click here to Skip to main content
13,045,657 members (65,946 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Wanting to use my ftp client that I built in c# to grab files from a unix ftp server, my current ftp client works well with windows type of an ftp server, but trying to connect to a Unix server there is an issue being detected by my ftp client suggesting "The URI prefix is not recognized.", here is my ftp client:
//The uri is/uriString: // I tried placing an ftp. at the begining but no help.
//port is: 21

private static string[] GetFilesToftp(string WildCard, string uriString, string etServer, string etUser, string etPassword)
         string ReturnStr = "";
         string ftpServer = etServer; 
         string ftpUser = etUser; 
         string ftpPassword = etPassword; 
         FtpWebRequest request = null;
         WebResponse response = null;
         Stream responseStream = null;
             request = WebRequest.Create(@uriString + WildCard) as FtpWebRequest;
             //Specify we are Listing a directory
             request.Method = WebRequestMethods.Ftp.ListDirectory;
             request.Credentials = new NetworkCredential(ftpUser, ftpPassword);
             //Get a reponse
             //response = request.GetResponse();
             response = (FtpWebResponse)request.GetResponse();
             responseStream = response.GetResponseStream();
             //Convert the response to a string
             int ch;
             while ((ch = responseStream.ReadByte()) != -1)
                 ReturnStr = ReturnStr + Convert.ToChar(ch);
             //split the string by new line
             string[] sep = { "\r\n" };
             string[] Files = ReturnStr.Split(sep, StringSplitOptions.RemoveEmptyEntries);
             return Files;
         catch (WebException wex)
             string Message = (wex.Message != null) ? wex.Message.ToString() : "";
             if (wex.Message.StartsWith("The remote server returned an error: (550) File unavailable"))
               return null;
             else if (wex.Message.StartsWith("The remote server returned an error: (530) Not logged in"))
               return null;
                 throw wex;
             if (responseStream != null)
             if (response != null)
Posted 18-Jun-12 9:52am
Updated 18-Jun-12 10:04am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I was able to log on to the Unix server, I only had to define the server location: now I need to know how I can chage firectory on this server then start downloading files from that location. Thanks in advance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100