Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 ASP.NET4.0
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.
 

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 15-Mar-13 3:30am
Edited 15-Mar-13 4:23am
Nelek59.4K
v4

1 solution

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

Solution 1

Hello Ajay,
 
You need following code to retrieve the list of files
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,
  Permalink  
v3

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2014
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