[英]SQL Server Compact edition 3.5 database acess is denied
I have developed a desktop application in C# with Microsoft SQL Server Compact Edition 3.5. 我使用Microsoft SQL Server Compact Edition 3.5在C#中开发了一个桌面应用程序。
It works fine when I run .exe
file from solution folder ( bin\\release
or debug
) but when I tried to deploy it by creating its setup it shows unhandled exception: 当我从解决方案文件夹(
bin\\release
或debug
)运行.exe
文件时它工作正常,但当我尝试通过创建它的设置来部署它时,它显示未处理的异常:
You don't have permission to access CustomersDB.sdf file.
您无权访问CustomersDB.sdf文件。
Note there is no path error it is correct. 请注意,没有路径错误,它是正确的。
string lokasifile = Environment.CurrentDirectory + "\\CustomersDB.sdf";
string stringkoneksi = "Data Source = \"" + lokasifile + "\"";
SqlCeConnection koneksi = new SqlCeConnection(stringkoneksi);
koneksi.Open();
SecurityException
This is nothing but caller does not have the appropriate permission. 这只不过是来电者没有相应的许可。 Environment.CurrentDirectory Property
Environment.CurrentDirectory属性
try
{
//Call Path here you will get to what the exactly error is
}
catch (Exception ex)
{
if (ex is DirectoryNotFoundException|| ex is IOException|| ex is SecurityException)
{
//Your handling here
}
else
{
throw;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.