Get Actual Filename from WebClient.DownloadFile

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

Greetings,

I'm using WebClient.DownloadFile to download a file.

This method requires that I provide the full filename. However, the URL
could be redirected to another page.

Is there any way to determine what the actual name of the file downloaded by
this method was?

Thanks!

Jonathan
 
Jonathan said:
I'm using WebClient.DownloadFile to download a file.

This method requires that I provide the full filename. However, the URL
could be redirected to another page.

Is there any way to determine what the actual name of the file
downloaded by this method was?
Try poking around in the .ResponseHeaders of the WebClient.

If all else fails, you can always *not* use WebClient and use
WebRequest/WebResponse directly. Not as convenient, of course.
 
Jonathan said:
I'm using WebClient.DownloadFile to download a file.

This method requires that I provide the full filename. However, the URL
could be redirected to another page.

Is there any way to determine what the actual name of the file
downloaded by this method was?
Try poking around in the .ResponseHeaders of the WebClient.

If all else fails, you can always *not* use WebClient and use
WebRequest/WebResponse directly. Not as convenient, of course.
 
Greetings,

I'm using WebClient.DownloadFile to download a file.

This method requires that I provide the full filename. However, the URL
could be redirected to another page.

Is there any way to determine what the actual name of the file downloadedby
this method was?

Thanks!

Jonathan

Hi,

The filename is of the local file. You can save it to a temp file or
prompt the user to select a filename/location.
FYI the filename on the server might be present in one of the header.
but you cannot assure it does exist (the header)
 
Greetings,

I'm using WebClient.DownloadFile to download a file.

This method requires that I provide the full filename. However, the URL
could be redirected to another page.

Is there any way to determine what the actual name of the file downloadedby
this method was?

Thanks!

Jonathan

Hi,

The filename is of the local file. You can save it to a temp file or
prompt the user to select a filename/location.
FYI the filename on the server might be present in one of the header.
but you cannot assure it does exist (the header)
 
Try poking around in the .ResponseHeaders of the WebClient.

If all else fails, you can always *not* use WebClient and use
WebRequest/WebResponse directly. Not as convenient, of course.

Well, I may need to do something like that anyway as I need to track
progress, support FTP, etc. I'm not familiar with these but will look them
over.

Thanks.

Jonathan
 
Try poking around in the .ResponseHeaders of the WebClient.

If all else fails, you can always *not* use WebClient and use
WebRequest/WebResponse directly. Not as convenient, of course.

Well, I may need to do something like that anyway as I need to track
progress, support FTP, etc. I'm not familiar with these but will look them
over.

Thanks.

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top