views:

111

answers:

2

Hello,

I am using asp.net/C#. I have a url to a folder on a remote server. In that folder are images that are all .jpgs. I don't know the names of the files, just that they are all .jpgs. How do I download all the .jpg images using asp.net/C# to a folder on my local hard drive.

Just to clarify. I am pulling files from a remote server and I am saving them to my local machine. I was given a web URL and told that the files I needed to pull down every night where .jpg image files. That's all I was told. I have no idea how I can get a list of files on a remote server with just the url to the folder.

Thanks

+1  A: 

If it's a web URL, you'd have to depend on the web server giving you some sort of list of files. The format of the list could be almost anything.

Put it this way: using a browser or anything else, how would you as a human find out all the filenames?

Just to clarify, are you writing code on the server which has the files? If so, you can find out what files are present using Directory.GetFiles. What do you want the user to have to do at the local side?

If you could make your question a bit clearer it would really help.

Jon Skeet
+1  A: 

Here is some concept code to work with

DirectoryInfo di = new DirectoryInfo("M:\MappedDrive");
 FileInfo[] rgFiles = di.GetFiles("*.aspx");
 foreach(FileInfo fi in rgFiles)
 {
  Response.Write("<br><a href=" + fi.Name + ">" + fi.Name + "</a>");       
 }
Noah