0

I have this code:

Dim Filename = "" 'I NEED TO GET THE FILE NEMAE
Using client As New WebClient()
client.DownloadFile("www.URL.com_that_redirects_to_random_file.pfx", "c:/" & Filename)
End Using

If I use

client.ResponseHeaders

It contains

Accept-Ranges: bytes
ETag: "95308f8df644d71:0"
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Sun, 09 May 2021 20:09:40 GMT
Content-Type: application/x-pkcs12
Last-Modified: Sun, 09 May 2021 17:12:55 GMT
Content-Length: 1542

But there is not the filaname

So How Can I get the filename of the redirect ? May I need to touch IIS ? As I cannot touch the "www.URL.com_that_redirects_to_random_file.pfx" as that server file gets a random string and resirects to a file based on random string get in a db

Filburt
  • 17,626
  • 12
  • 64
  • 115
Devmyselz
  • 346
  • 3
  • 13
  • Normally, that information would be in the `content-disposition` header, but if you aren't getting that header back, the server may not be dishing it out to begin with. Perhaps see https://stackoverflow.com/a/13571471/6530134 - it's C#, but you should be able to translate to VB.NET. Also, if you can, you should avoid using `WebClient`, [it's not recommended for use](https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient?view=net-5.0#remarks) – Timothy G. May 09 '21 at 20:36
  • Maybe there isn't a file name to begin with. You're downloading data that may or may not come from a file. If it gets generated on the fly then there's no file to have a name in the first place. – jmcilhinney May 10 '21 at 02:55

0 Answers0