question

Gowsalya-1806 avatar image
0 Votes"
Gowsalya-1806 asked Viorel-1 edited

Download csv file from url without filename in c# console

Hi,
I am trying to download a csv file from url without filename.
The filename differs so the url will not have filename.

Can anyone guide me.

Thanks in advance.

dotnet-csharpdotnet-cli
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It's not possible to download a file without knowing a file name. Perhaps you need to talk to the site owner about possibilities such as either an API or something in one of the files like date time or something else to identify the file.

0 Votes 0 ·

Yes I asked, only one filename as 'vision_inventory.csv' will be there. But it is not given in url as url click shows a button, on submit of it the file downloads.

0 Votes 0 ·

Can you give me idea for it

0 Votes 0 ·
OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered Gowsalya-1806 commented

I am trying to download a csv file from url without filename.

How could that be possible, without a filename?
There may be some some thousand files on the server and you want to download one specific; without using the filename?
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

No, there will be only one file in it,which downloads on loading the link, I want to do it through code

0 Votes 0 ·
Viorel-1 avatar image
1 Vote"
Viorel-1 answered Viorel-1 edited

Maybe you need something like this:

 string url = @". . ."; // the URL without file name
    
 using( WebClient wc = new WebClient( ) )
 {
     // download and save to local file
     wc.DownloadFile( url, "MyFile.csv" );
    
     // or download to a string variable
     string csv = wc.DownloadString( url );
     . . .
 }

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.