Error in Ftp downloading process
Hi,
I am working in an appication where i have to download and upload files from ftp server. File upload process is working fine. But when i am trying to fetch all the file names from a folder in ftp server, it shows me an error "The remote server returned an error: (503) Server Unavailable."
The code is as follow
private string[] GetFiles(string WildCard)
{
string ReturnStr = "";
FtpWebRequest request = WebRequest.Create("ftp://machine IP/FolderName/" + WildCard) as FtpWebRequest;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential("", "");
StringWriter sw = new StringWriter();
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
int ch;
while ((ch = responseStream.ReadByte()) != -1)
ReturnStr = ReturnStr + Convert.ToChar(ch);
responseStream.Close();
response.Close();
string[] sep = {"\r\n"};
string[] Files = ReturnStr.Split(sep, StringSplitOptions.RemoveEmptyEntries);
return Files;
}
Thanks in Advance.
|