Click here to Skip to main content
11,583,865 members (44,414 online)
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 2:30am
Edited 15-Mar-13 3:23am
Nelek71.1K
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)

  Print Answers RSS
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 314
2 virusstorm 268
3 Richard Deeming 220
4 Dave Kreskowiak 200
0 OriginalGriff 1,623
1 Sergey Alexandrovich Kryukov 1,135
2 Abhinav S 701
3 Dave Kreskowiak 627
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2015
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