Create folder o Save to Temp

I have Visual Studio 11 (Windows 8 developer), I created a bootloader 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 does not work! If I changed the folder "C: \ Windows \ Temp" to "E: \ Temp", start the download. Drive C: \ does not work, why? Can I save to temp folder or do you have another idea?

+4
source share
5 answers

try the following:

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

Does it work?

+3
source

Without playing with Widnows 8, this is only a hypothesis, but most likely you do not have write permissions to this place in C: \ as a standard user privilege.

+4
source

Use an environment variable instead

 Environment.GetFolderPath(Environment.LocalApplicationData) 
+2
source

You can use the path to the temp folder:

 string tempPath = System.IO.Path.GetTempPath(); 
+2
source

Use one of the following actions:

0
source

All Articles