clickonce-向数据目录写入/读取是否需要管理员权限? [英] clickonce - does writing/reading to the Data Directory required Admin rights?

查看:109
本文介绍了clickonce-向数据目录写入/读取是否需要管理员权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景-我正在考虑使用clickonce通过clickonce(通过网站)部署WinForms应用。相对简单的应用程序的元素是:
-它是一个可执行文件,并且一个数据库文件(sqlite)
-数据库(sqlite)有时需要由应用程序进行更新(例如,添加表,添加列) )
-当然,在整个升级过程中,数据库数据(只是sqlite的文件)需求仍然存在

Background - I'm looking at using clickonce for deployment of a WinForms app via clickonce (via website). The elements of the relatively simply application are: - it is an executable and one database file (sqlite) - database (sqlite) will need to be updates sometimes by the application (e.g. add table, add column) - database data (which is just a file for sqlite) needs remain across upgrades of course

假设-我假设在clickone下允许上述操作的最佳方法是:

Assumption - I'm assuming here that the best way to allow for the above under clickone is to:


  • 使用数据目录查找sql​​ite数据库文件的位置

  • 将智能写入MainForm加载方法以:


    • 检查是否需要创建数据库文件以编程方式(通过ApplicationDeployment.CurrentDeployment.IsFirstRun)在数据目录(DD)中,或者如果没有,则将现有数据库文件从PRE区域(clickonce应该已经对其进行了复制)复制到DD主区域

    • 检查DD中数据库文件的版本,然后更新

    问题-上面说明了对ClickOnce具有特殊访问权限(管理员或特权提升)以读取/写入/形成数据目录的任何要求吗?那是我可以假设最基本的用户PC能够做到这一点(

    Question - Is there any requirement for ClickOnce to have special access (Admin, or elevated priviledge) to read/write to/form the Data Directory are described above? That is can I assume the most basic user's PC should be able to do this (either a home PC, or work PC in an organisation) in general.

    谢谢

    推荐答案

    我建议(最简单的操作)是将文件(我认为是SQLLite数据库)添加为现有资源,右键单击它,转到属性,将构建操作更改为Content,然后复制到输出目录到复制,如果较新。

    What i would suggest (easiest to do) is add the file(SQLLite database I believe) as an existing resource, right click it, go to properties and change build action to Content, and Copy to output directory to "Copy if newer".

    从这里您有2个选择:

    如果您永远不会更改更新时保留原始SQL文件,则可以保留该原始文件,但是如果您想一次又一次地进行更改,建议您执行以下操作:

    If you won't ever change the original SQL File when updating then you can leave it as that, but if you're looking to make changes now and again, I would suggest the following:

            String appPath = Path.GetDirectoryName(Application.ExecutablePath);
    
            if (!System.IO.File.Exists(appPath + @"\Resources\SQLLite.db"))
            {
                System.IO.File.Copy(appPath + @"\Resources\SQLLiteIncluded.db", appPath + @"\Resources\SQLLite.db");
            }
    

    如果需要,可以将其复制到当前用户的应用程序数据文件夹中该程序将无法对其可执行路径进行写访问(大多数情况下都具有此权限)

    If need be, you can copy to a the current users application data folder if the program will not have write access to its executable path(most instances it does)

    \Resources\是我在项目中创建的文件夹(复制到可执行文件路径(如果其中包含内容的文件),因此为什么在路径中包含它。 (这是可选的)。

    \Resources\ is a folder I have created in my project, (which gets copied to the executable path if there's files inside it that are content) hence why I included it in the paths. (This is optional)

    关于管理权限,我在网络上不需要任何管理权限,但是我们通过网络驱动器(而不是网站)进行部署,但是我会假设相同。

    Regarding the administrative rights, I don't need any administrative right for this on our network, but we deploy via network drive not a website, but I would assume it would be the same.

    这篇关于clickonce-向数据目录写入/读取是否需要管理员权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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