Visual Studio 安装部署项目 - 如何指定文件系统安装文件夹
如何指定产品安装的默认位置并为日志文件、临时文件创建其他文件夹?
例如,如果我决定将应用程序的每个实例安装在路径
C:\Documents and Settings\\Application Data\ 中,即我想要安装应用程序的位置,即 DLL、可执行文件都需要在那里。
C:\Documents and Settings\\Application Data\\LogFiles 是我要写入日志文件的位置。
C:\Documents and Settings\\Application Data\\Temporary Files 是我想要写入程序将生成的临时文件(并随后删除)的位置,
因此,我希望我的安装程序创建主文件夹和子文件夹。
此外,我想以某种方式编写我的 AppName.exe.config,使其指向上面创建的子文件夹。
我如何实现同样的目标。
我的环境详细信息:
Visual Studio 2008 C#
How do I specify Default Location of where my Product is to be installed and create additional folders for Log Files, Temporary Files?
For instance, if I decide to install every instance of my application in the path
C:\Documents and Settings\\Application Data\ is where I want to install my Application, that is, the DLL's, Executables all need to be there.
C:\Documents and Settings\\Application Data\\LogFiles is where I want to write the Log Files.
C:\Documents and Settings\\Application Data\\Temporary Files is where I want to write the Temporary Files that my program will generate (and delete thereafter)
So, I want my Setup to create the main folder and the sub-folders.
In addition, I want to write my AppName.exe.config in a way, that it points to the above created sub-folders.
How do I achieve the same.
My Environment Details:
Visual Studio 2008
C#
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些都不是合适的路径。您的应用程序需要进入 c:\program files\manufacturer\productname。您的临时文件需要进入 Path.GetTempPath ,以便当您的应用程序崩溃并忘记清理临时文件时它们会被清理。在运行时查找目录。您的日志文件需要进入 c:\documents and settings\username\application data\ 文件夹。在运行时使用Environment.GetFolderPath()查找目录。不要在 app.exe.config 中存储路径
这可确保您的应用程序将在任何 Windows 版本上安装和运行。
These are not appropriate paths. Your app needs to go into c:\program files\manufacturer\productname. Your temporary files need to go into Path.GetTempPath so that they'll get cleaned-up when your app crashes and forgets to clean up the temporary files. Find the directory at runtime. Your log files need to go into c:\documents and settings\username\application data\ folder. Find the directory at runtime with Environment.GetFolderPath(). Don't store paths in app.exe.config
This ensures your app will install and run on any Windows version.