.net安装程序并设置文件扩展名 [英] .net installer and setting up file extensions

查看:67
本文介绍了.net安装程序并设置文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于安装人员来说,我是一个完全的新手,但是到目前为止,我已经取得了不错的进展.我被困在一个我无法完全理清的方面.我安装的应用程序有一些可执行文件可以正常运行的文件.作为安装程序的一部分,我已经在桌面和开始"菜单等地方成功创建了快捷方式.但是,当我添加文件类型时,无法获得相同类型的行为.因此,如果我添加文件类型,然后将命令设置为在应用程序文件夹中找到的主要输出,那么我希望它会起作用.但是,安装后,我可以通过一些错误日志告诉我,我的应用程序中有错误日志,它正在查找与我刚刚单击的扩展名而不是应用程序文件夹相关的文件.因此,与其查找c:\ Programs(x86)\ MyCompany \ MyApp \ Settings.xml,而是在c:\ MyFileFolder \ Settings.xml中查找Settings.xml,因为我单击的文件位于c:\ MyFileFolder. />
显然,这会导致依赖该文件的操作失败.我无法弄清楚我在这方面做错了什么.有人知道我在想什么吗?我已经按照一些MSDN演练中的步骤进行了操作,但是他们没有说任何警告我这个问题的方法.我尝试查看是否可以浏览到为安装创建的快捷方式,但是该快捷方式不起作用.

I am a complete newb to installers, but so far I have made decent progress. I am stuck on one aspect that I can''t quite sort out. My installed application has a few files that the executable works with in order to function. I have successfully created shortcuts in places like the desktop and start menu as part of my installer. However I can''t get the same type of behavior to work when I add a file type. So if I add the file type, and then set the command to be the primary output found in the application folder, then I would have hoped that would work. However, once I install, I can tell by some error logs I have in my app that it is looking for files relative to the file with the extension I just clicked on, not relative to the application folder. So rather than looking for c:\Programs(x86)\MyCompany\MyApp\Settings.xml it looks for Settings.xml in c:\MyFileFolder\Settings.xml because the file that I clicked was in c:\MyFileFolder.

That obviously causes actions that depend on that file to fail. I can''t figure out what I am doing wrong on this. Does anyone know what I am missing? I have followed the steps on some MSDN walkthroughs but they don''t say anything that would warn me about this issue. I tried seeing if I could browse to a shortcut that I have created for the installation, but that wasn''t working.

推荐答案

正在读取应用程序的位置应该使用以下路径访问settings.xml文件之类的文件:
The places where you are reading application files like a settings.xml file should be accessed with the following path:
System.AppDomain.CurrentDomain.BaseDirectory+"\\settings.xml" 



这样会创建一个与exe所作用的工作目录无关的路径.



That creates a path that will work independent of the working directory the exe is acting in.


这篇关于.net安装程序并设置文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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