简体   繁体   English

创建文件夹o保存在Temp中

[英]Create Folder o Save in Temp

I have Visual Studio 11 (Windows 8 Developer) i have create a downloader file: 我有Visual Studio 11(Windows 8开发人员)我创建了一个下载程序文件:

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. 如果我在“E:\\ Temp”中更改文件夹“C:\\ Windows \\ Temp”,则下载开始。 The drive C:\\ doesn't work, why? 驱动器C:\\不起作用,为什么? 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: 使用以下之一:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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