安裝後的應用程序提供了錯誤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