Ask a Question related to ASP.NET General, Design and Development.
-
CodeMotion #1
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
CodeMotion Guest
-
Default download directory for IE 7
Hi, Can the default download directory be changed? In previous versions of IE it just took the last used download directory, now each time i... -
Upload/Download Files on Network File Server
I was hoping that someone can give me step-by-step instructions to fix the following: We would like our ASP.NET application to utilize a central... -
Read file knowing PRECISE end of each line
Hallo I'd like to parse a file but knowing where EXACTLY the end of each line is (that is: at which byte, included), so to browse it line by... -
rsync exclude file - directory name without directory contents
When using rsync to maintain incremental backups significant space can be saved on the backup server by excluding directories that have non-critical... -
knowing when a file download is complete
I have a requirement to record in a database when a file is finished downloading to the end-user. Currently when a user clicks a download icon for...



Reply With Quote

