I'm using client.DownloadFile(); for my console project.. now my question is: if my command goes like this:
client.DownloadFile(http://url.com/random-name, "filename")
what i need is instead of downloading the file and save it as "filename" i want the filename to be "what ever the random file name is" is that possible?
Get the filename using Path.GetFileName. You can get the AbsoluteUri property of your URI, or just pass the full URI yourself like you've done in your post.
string filename = System.IO.Path.GetFileName(myUri.AbsoluteUri);
client.DownloadFile(myUri, filename);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With