Bxcb Sbdsb
Bxcb Sbdsb

Reputation: 105

Using client.DownloadFile();

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?

Upvotes: 3

Views: 799

Answers (1)

keyboardP
keyboardP

Reputation: 69372

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);

Upvotes: 2

Related Questions