使用设置绑定内容文件 [英] Bind content files with setup

查看:78
本文介绍了使用设置绑定内容文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在visual studio中有一个应用程序。在该应用程序中,我有一个.txt / .xml文件,它存储了一些数据(我们可以说我已经使用了文件而不是数据库来存储数据),这是运行时应用程序所需要的。文件在调试文件夹中存储/创建。在我的应用程序中,它工作正常。现在我想为该项目创建设置,但是当我创建设置时,它不会导致文件并给我错误''文件未找到/访问被拒绝''因为文件不存在。现在我的问题是如何包含该文件以及如何授予该文件访问(读/写)它的权限。

解决方案

以下文章应该帮助/指导你:使用Visual Studio安装程序为C#Windows应用程序创建MSI包项目 [ ^ ]


我认为你说这个文件在开发时与.exe文件(即Debug目录)在同一个目录中(工作正常)但部署时不起作用。这不是一个好习惯。该文件应设置为在与应用程序相关的可写目录中使用。一个简单的例子是应用程序的C:\Program Files \ myapp \ appfile.exe和C:\Users\me\Documents\myapp\appfile.xml。这些是简单的示例,您应该通过向操作系统询问正确的父目录名称来概括细节(这些名称因操作系统语言和32/64位操作系统而异)。如果数据是静态的,则应由.msi安装;如果它是动态的,它应该在你的应用程序运行时有条件地编写和维护(例如,你想在更新到更新版本的软件时覆盖它吗?)。



我不是很好地解释自己。 此处 [ ^ ]是一篇很棒的文章,提供了更强大的细节。

I have an application in visual studio. In that application i have an .txt/.xml file which stores some data(we can say i have used file instead of database to store data) which is needed for application while running. File is stored/created in debug folder. In my application it is working parfactly alright. now i want to create setup for that project but when i create setup it is not inducing the file and giving me error ''file not found/access is denied'' because of file is not there. Now my question is how to include that file and how to give permission to that file to access(read/write) it.

解决方案

Following article should help/guide you: Creating an MSI Package for C# Windows Application Using a Visual Studio Setup Project[^]


I think you are saying that the file is in the same directory as the .exe file (ie. Debug directory) when you are developing (which works fine) but does not work when deployed. This is not a good practice. The file should be set up to be used in a writable directory relevant to the application. A simplistic example would be "C:\Program Files\myapp\appfile.exe" for the app and "C:\Users\me\Documents\myapp\appfile.xml". These are simplistic examples and you should generalize the details by asking the operating system for the correct parent directory names (these differ by OS language and 32/64 bit OS for example). If the data is static it should be installed by the .msi; if it is dynamic it should be conditionally written and maintained by your app when it runs (eg. do you want to overwrite it when you update to a newer version of the software?).

I am not explaining myself very well. Here[^] is an excellent article that gives more robust details.


这篇关于使用设置绑定内容文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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