Adding Files to a Click Once Deployment

会有一股神秘感。 提交于 2019-12-27 22:11:07

问题


I've got an application that I'm moving over to ClickOnce and the app has a moderately sized data folder with hundreds of files that I need to inlcude in the deployment. The folder needs to be in the same place relative to the EXE after deployment. I've seen several suggestions on how to do this but there doesn't seem to be a agreed upon method for doing this.

Any suggestions would be great -

Thanks!


回答1:


One good way of doing this is:

  • Create a folder under the app in VS name e.g. "datafiles"
  • Add all files to that folder using Add as link in the dialog box after selecting Add existing item on the folder
  • Mark all files as Copy if newer (Copy to output directory property)
  • Make sure the build action is content

--> when you publish the files will be put in that folder and be a part of the application installation

Good luck!




回答2:


After deployment, all files marked as data are placed in the ApplicationDeployment.DataDirectory folder. I know of no way to change this. You could copy the data files during the first run of your app, but this approach will not survive any upgrades that include data file changes.

Alternatively if you have control over the location of the data folder during development, you can place in the same relative (to the app folder) location as will be specified after deployment.




回答3:


https://msdn.microsoft.com/en-us/library/kzy0fky2.aspx

https://msdn.microsoft.com/en-us/library/6fehc36e.aspx

These two articles provide methods of doing this. Between the two of thing you can find one that works for you. The one that worked for me was:

With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Publish tab. Click the Application Files button to open the Application Files dialog box. In the Application Files dialog box, select the file that you wish to mark as data. In the Publish Status field, select Data File from the drop-down list.



来源:https://stackoverflow.com/questions/940025/adding-files-to-a-click-once-deployment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!