以下是电子邮件临时商店附件的代码。这段代码适用于我的应用程序。当我折痕EXE文件。我收到这个错误:
"访问路径' C:\ Program Files(x86)\ Application Name \ Temp'是 否认"
if (!Directory.Exists(String.Format("{0}\\Temp", Application.StartupPath)))
Directory.CreateDirectory(String.Format("{0}\\Temp", Application.StartupPath));
FileInfo f = new FileInfo(String.Format(@"{0}\Temp\{1}", Application.StartupPath, Atchment.Filename));
if (!f.Exists)
{
using (var fs = new FileStream(String.Format(@"{0}\Temp\{1}", Application.StartupPath, Atchment.Filename), FileMode.Create))
{
int fileLength = (int)Atchment.FileSize;
byte[] rawdata = (byte[])Atchment.File;
int byteCount = rawdata.Length;
fs.Write(rawdata, 0, byteCount);
}
}
我已经DirectorySecurity folderSecurity = Directory.GetAccessControl(path);
同意了,但它没有成功。我做错了什么?