Multiple file download from network drive via web

  • Thread starter Thread starter ghart
  • Start date Start date
G

ghart

Hello all,

I have been trying to determine the best way to do this, but can't
seem to get any solution to work exactly the way I want. The scenario
is that I have some xml files being placed on a network drive of one
of our servers. I needed to copy this files to my web server to do
processing. Ideally I was going to write a server service that
monitor wold monitor that directory so that when a new file appeared
it was automatically copied and I may still look at doing that.

However right now I am just trying to perform a copy of the whole
directory contents via a link in my ASP.NET/C# web app. One thing I
did was to create a virtual directory on my iis box, set it up as an
application and point it to the UNC of the file. That seems to work.
Then Ifound some sample code:

string RemoteFolder = @"http://www.bogussite.com/123/";
string RemoteFile = "123.xml";
string url = RemoteFolder + RemoteFile;
HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create(url);
HttpWebResponse webResponse =
(HttpWebResponse)webRequest.GetResponse();
StreamReader sr = new
StreamReader(webResponse.GetResponseStream());
string filecontent = sr.ReadToEnd();
StreamWriter sw = new StreamWriter(@"C:\Inetpub\wwwroot
\putthemhere\123.xml");
sw.Write(filecontent);
sw.Flush();
sw.Close();
sr.Close();

This works great, but only copies one file and doesn't seem to like
wild cards, *.xml would be ideal. I also look at trying to use
WebClient.download file but that did not seem to work for multiple
files either.

Any thoughts would be appreciated.
Greg
 
http unlike ftp does not support directory directives or multiple file
download.

you could add an aspx page or webservice that returned a directory listing.
you could also turn on directory browsing. with directory browsing, a get of
the site root returns a directory list. you woudl have to pase the list
becuase its not in a standard format.

-- bruce (sqlwork.com)
 
Welcome to the programming....
Sometimes you will have to write code yourself, the code you have is a good
start :)


George.
 
Back
Top