Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
I have a url for a file something like "http://my.domai.com/myfile.doc" and if I open this in browser, a popup opens to enter username and password, after that I can view or download file. Now I have to do this download in my win 8.1 app. I used code below:

C#
BackgroundDownloader backgroundDownloader = new BackgroundDownloader();
var credentials = GetNetworkCredential();
backgroundDownloader.ServerCredential = new Windows.Security.Credentials.PasswordCredential("Lighthouse", credentials.UserName, credentials.Password);
CancellationTokenSource cts = new CancellationTokenSource();

DownloadOperation downloadOperation = backgroundDownloader.CreateDownload(new Uri(System.Net.WebUtility.UrlDecode(searchDoc.Path)), fileToSave);
downloadOperation.StartAsync();


But nothing happens, no error no data. Can anyone help?
Posted
Updated 24-Jun-14 19:00pm
v2

1 solution

This is not a valid URL. Valid URL should start with the URI Scheme "http://" or perhaps "https://". You domain should be known to the DNS, prescribed in the DNS data.

Please see:
http://en.wikipedia.org/wiki/URI_scheme[^],
http://en.wikipedia.org/wiki/DNS[^].

—SA
 
Share this answer
 
Comments
mayankkarki 25-Jun-14 1:00am    
Sorry if I not mentioned http://, but its there in the code I am running.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900