EDN Admin
Well-known member
Hello all,
I need to download a file programatically. I am coding this as a C# console application.
I have the code to download and it works fine. I give my console app the target file and it goes to download it and saves it to the right location. All my download code works.
Heres exactly what Im running into:
I need to download a file from a url that has query strings after the file name. The way I assume this websites code works is you go to the url where you can download your database, you provide the proper query strings (id=13980 for instance) and a download file dialog pops up where you then click save and it downloads your database.
More math than words... The url would looks something like this (actual query strings and url are changed for confidentiality...)
https://www.website.com/downloadLocation/DatabaseDate.mdb?ID=90752&AUTH=569023 https://www.website.com/downloadLocation/DatabaseDate.mdb?ID=90752&AUTH=569023 (not a real link by the way... )
I have tried just pointing my WebClient.DownloadFile towards the full url including query strings and saving it to a DatabaseDate.mdb which doesnt work (duh).
I have also tried doing WebClient.QueryString.Add("ID", "90752")... , using the target url as https://www.website.../DatabaseDate.mdb https://www.website.../DatabaseDate.mdb (no query strings in target url), and downloading that to DatabaseDate.mdb, also to no avail.
And finally, I have tried doing the previous step but following the url ".../DatabaseDate.mdb" with a "?" - (".../DatabaseDate.mdb?").
Every time I try any of the afformentioned steps, it downloads the html from the page in .mdb format (the file extension I specify in the WebClient.DownloadFile() . Does anyone have any suggestions? Any would be greatly appreciated.
Regards,
Aaron Ball
View the full article
I need to download a file programatically. I am coding this as a C# console application.
I have the code to download and it works fine. I give my console app the target file and it goes to download it and saves it to the right location. All my download code works.
Heres exactly what Im running into:
I need to download a file from a url that has query strings after the file name. The way I assume this websites code works is you go to the url where you can download your database, you provide the proper query strings (id=13980 for instance) and a download file dialog pops up where you then click save and it downloads your database.
More math than words... The url would looks something like this (actual query strings and url are changed for confidentiality...)
https://www.website.com/downloadLocation/DatabaseDate.mdb?ID=90752&AUTH=569023 https://www.website.com/downloadLocation/DatabaseDate.mdb?ID=90752&AUTH=569023 (not a real link by the way... )
I have tried just pointing my WebClient.DownloadFile towards the full url including query strings and saving it to a DatabaseDate.mdb which doesnt work (duh).
I have also tried doing WebClient.QueryString.Add("ID", "90752")... , using the target url as https://www.website.../DatabaseDate.mdb https://www.website.../DatabaseDate.mdb (no query strings in target url), and downloading that to DatabaseDate.mdb, also to no avail.
And finally, I have tried doing the previous step but following the url ".../DatabaseDate.mdb" with a "?" - (".../DatabaseDate.mdb?").
Every time I try any of the afformentioned steps, it downloads the html from the page in .mdb format (the file extension I specify in the WebClient.DownloadFile() . Does anyone have any suggestions? Any would be greatly appreciated.
Regards,
Aaron Ball
View the full article