[英]Deploying application
I'm just deploying a winform app that uses SqlCe. 我只是在部署使用SqlCe的Winform应用程序。 I'm using the 'Setup and Deployment\\Setup Project' to customise my deployment.
我正在使用“安装和部署\\安装项目”来自定义我的部署。 I've created a 'User's Application Data Folder' for all my sdf files to go into (from what I've read this is best practice, correct me if I'm wrong).
我为所有要插入的sdf文件创建了一个“用户的应用程序数据文件夹”(从我读到的这是最佳实践,如果我错了,请更正我)。 Now I want to re-map (for lack of a better work) the connection strings from
现在,我想重新映射(由于缺乏更好的工作)来自
connectionString="Data Source=|DataDirectory|\My.sdf"
to 至
connectionString="Data Source=C:\Users\Chris\AppData\Roaming\My Application\My.sdf"
This is where I'm stuck. 这就是我卡住的地方。 How do I do this so as it work on multiple users and OS's (I believe putting the sdf files into C:\\Users\\Chris\\AppData\\Roaming\\My Application is best for multi OS's)?
我如何做才能在多个用户和OS上正常工作(我相信将sdf文件放入C:\\ Users \\ Chris \\ AppData \\ Roaming \\ My Application最适合多OS)?
You can retrieve the AppData
-folder using the following: 你可以检索
AppData
-folder使用以下:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Adding your desired path can be done using Path.Combine
: 可以使用
Path.Combine
添加所需的路径:
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Roaming\\My Application");
The result-path is the AppData-folder for the user that runs the code. 结果路径是运行代码的用户的AppData文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.