如何强制我的.NET应用程序以管理员身份运行也可以访问sqlite? [英] How do I force my .NET application to run as administrator also access sqlite?

查看:117
本文介绍了如何强制我的.NET应用程序以管理员身份运行也可以访问sqlite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have create Set up file for WPF application and the database is SQLite DB. After the installation the SQLite DB is located this path in C folder, and the application is running properly on any computer that without an administrator Password PC.

C:\Program Files (x86)\myCompany\myScanApp.







public SQLiteConnection dbConnection = new SQLiteConnection(@"Data Source=C:\Program Files (x86)\myCompany\myScanApp\test.s3db;");







The problem is, it is failing to login after running this application if any other administrator password set PC. How can I solve this problem?

How can I access Sqlite DB from C drive after installation WPF application if pc have administrator password ?





我尝试过:



我正在使用此连接字符串: -





What I have tried:

I am using this connection string:-

public SQLiteConnection dbConnection = new SQLiteConnection(@"Data Source=C:\Program Files (x86)\myCompany\myScanApp\test.s3db;");

推荐答案

首先,您的数据库不应该在Program Files下。 Program Files下的所有内容都是ReadOnly。我猜这可能是你认为你需要管理员权限来运行你的应用程序的原因。不要。



正确的解决方案是将数据库放在更合适的文件夹下,例如C:\ ProgramData \ 公司 \的 APPNAME 的。这个位置是每个人的ReadWrite。您还必须更改连接字符串以指向它。
First, you database should NOT be under Program Files. Everything under Program Files is ReadOnly. I'm guessing that's probably why you think you need admin permissions to run your app. Don't.

The correct solution is to put your database under a more appropriate folder, like C:\ProgramData\company\appName. This location is ReadWrite for everyone. You'll also have to change the connection string to point to it there.


这篇关于如何强制我的.NET应用程序以管理员身份运行也可以访问sqlite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆