简体   繁体   中英

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?

还没有玩过Widnows 8,这只是猜想,但是你可能没有对C:\\上的那个位置的写权限作为标准权限用户。

try with this:

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

does it work?

请改用环境变量

Environment.GetFolderPath(Environment.LocalApplicationData)

您可以使用临时文件夹路径:

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

Use one of the following:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM