469,579 Members | 1,098 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

WebRequest - download files from directory without knowing name of file

I have access to an internet directory and files will be placed in
this directory periodically. I am writing a service to poll that
directory and download the files for processing. I have figured out
how to download the files if I have the name of the file. However, I
will not know the names of these files that I need to download. So,
Is there a way to download a file from a directory in which you do not
know the name of the file?

I am currently using the HttpWebRequest/HttpWebResponse objects to do
this. Here is some code that accomplishes my task.
************************************************** *******************
Dim site As String =
"https://somedomain.com/somedirectory/somefilename.xml"
Dim authuri As String = "https://somedomain.com"
Dim userName As String = "u"
Dim password As String = "p"
Dim domain As String = "www.somedomain.com"
Dim receipt As String = Nothing

'Prepare authentication header
Dim einfoCache As New CredentialCache()
einfoCache.Add(New Uri(authuri), "Basic", New
NetworkCredential(userName, password))
einfoCache.Add(New Uri(authuri), "Digest", New
NetworkCredential(userName, password, domain))

Dim request As WebRequest = HttpWebRequest.Create(site)
With request
.Credentials = einfoCache
.PreAuthenticate = False
.ContentType = "text/xml"
.Method = "GET"
End With

Dim response As WebResponse = request.GetResponse()
Dim reader As StreamReader = New
StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8)
receipt = reader.ReadToEnd()
****Code Omitted From Here Down****
************************************************** *******************

The 'site' var is the problem child. I can download the file if I
know the name but I need to be able to find the name...then download
it. Any help will be greatly appreciated.

Thanks
Nov 17 '05 #1
0 3125

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Ken | last post: by
3 posts views Thread by Skwish | last post: by
8 posts views Thread by John K. | last post: by
1 post views Thread by Richard K Bethell | last post: by
1 post views Thread by rdemyan via AccessMonster.com | last post: by
2 posts views Thread by kkb | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.