如何获取C盘应用程序文件夹的访问权限?

时间:2015-09-03 13:48:45

标签: c# windows

以下是电子邮件临时商店附件的代码。这段代码适用于我的应用程序。当我折痕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);同意了,但它没有成功。我做错了什么?

0 个答案:

没有答案