Click here to Skip to main content
15,909,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The Below Give Code is giving the data in dataset for one file because i specified the name . but i want all xmlfile when i rtemove that file name.


C#
System.Net.FtpWebRequest tmpReq = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create("ftp://72.3.247.174/34380.xml");
        tmpReq.Credentials = new System.Net.NetworkCredential("ppp", "778");
        tmpReq.Method = WebRequestMethods.Ftp.ListDirectory;

      
        using (System.Net.WebResponse tmpRes = tmpReq.GetResponse())
        {
            //GET THE STREAM TO READ THE RESPONSE FROM
            using (System.IO.Stream tmpStream = tmpRes.GetResponseStream())
            {
                
                DataSet ds = new DataSet();
                ds.ReadXml(tmpStream);

            }
        }

[edit]code block added[/edit]
Posted
Updated 15-Mar-13 3:23am
v4

1 solution

Hello Ajay,

You need following code to retrieve the list of files
C#
string strResp = String.Empty;
FtpWebRequest request = (FtpWebRequest) WebRequest.Create("ftp://72.3.247.174/");
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new System.Net.NetworkCredential("ppp", "778");
using(FtpWebResponse response = (FtpWebResponse) request.GetResponse())
{
    using(StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
         strResp = reader.ReadToEnd();
    }
}

All that will be left is to parse this response and create a dataset. The best demo of this can be found here[^] on CodeProject.

Regards,
 
Share this answer
 
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900