Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Folder o Save in Temp

I have Visual Studio 11 (Windows 8 Developer) i have create a downloader file:

string sUrlToReadFileFrom = "http://mysite/1.mp3";
int iLastIndex = sUrlToReadFileFrom.LastIndexOf('/');
string sDownloadFileName = sUrlToReadFileFrom.Substring(iLastIndex + 1, (sUrlToReadFileFrom.Length - iLastIndex - 1));
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("http://mysite/1.mp3"), "C:\\Windows\\Temp" + "\\" + sDownloadFileName);

But it doesn't work start! If I change the folder "C:\Windows\Temp" in "E:\Temp" the download start. The drive C:\ doesn't work, why? It is possible save in temp folder or you've other idea?

like image 406
Win8Dev Avatar asked Dec 21 '22 08:12

Win8Dev


2 Answers

Not having played with Widnows 8 yet, this is only conjecture, but it's likely you don't have write permissions to that location on the C:\ as a standard privilege user.

like image 125
Joel Coehoorn Avatar answered Dec 24 '22 01:12

Joel Coehoorn


try with this:

string tempPath = System.IO.Path.GetTempPath();

does it work?

like image 36
Davide Piras Avatar answered Dec 24 '22 00:12

Davide Piras