安装后的应用程序提供了错误Acess Denied。读取和写入文件。格兰特阅读权限
拒绝访问该文件
PathName\\BLsms.ocx
这里PatheName是完整路径。
Advance安装程序用于创建安装程序。
然后应用程序安装在C Drive
。
如何让这些文件可读写?
我正在使用此代码。
try
{
this.brlmfc = new BinaryReader(new FileStream("BLsms.ocx", FileMode.Open, FileAccess.ReadWrite,FileShare.Read));
this.brocx = new BinaryReader(new FileStream("BLrpi.lfc", FileMode.Open,FileAccess.ReadWrite));
this.brlmc = new BinaryReader(new FileStream("rpcgh.lfc", FileMode.Open,FileAccess.ReadWrite));
this.passkey1 = this.brlmfc.ReadString();
this.passkey2 = this.brocx.ReadString();
this.passkey3 = this.brlmc.ReadString();
}
catch (Exception e13)
{
MessageBox.Show(e13.Message);
i = 0;
}
我也尝试了下面的代码在Form Load方法中。
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.AllAccess, Application.StartupPath+"\\BLsms.ocx");
f2.AddPathList(FileIOPermissionAccess.Read, Application.StartupPath+"\\BLrpi.lfc");
f2.AddPathList(FileIOPermissionAccess.Read, Application.StartupPath+"\\Brpcgh.lfc");
f2.Demand();
您是否正在使用'Application.StartupPath +“BLsms.ocx”'获得正确的路径,或者您必须使用'Application.StartupPath +“\ BLsms.ocx”' – Sandeep
是的,我在安装完文件后。路径是C:\ Program Files(x86)\ MyFolder \ Myapp \ BLsms.ocx –
请尝试'FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.AllAccess,Application.StartupPath + @“\ BLsms.ocx”);'也为其他两个文件 – Sandeep