30

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!

user91089
  • 303
  • 1
  • 4
  • 5
  • andyhammar answer +. We need to see if under Project -> Properties - Publish-> Application files are Included if one click app is published. – sPS Mar 28 '19 at 10:30

3 Answers3

53

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!

andyhammar
  • 1,443
  • 13
  • 19
  • 1
    Also, if you want to include your file links to the application files when publishing, make sure to set Build Action to "Content" on the linked files. – Zebaz Apr 06 '13 at 16:11
  • I didnt see an "Add as Link" option, so I just added the files to the folder, then afterwards selected them all, right clicked and brought up the properties window, and chose the following options "Copy to Output Directory:Copy if newer" and "Build Action: Content", and it worked fine. Thanks! – Brad Parks Aug 14 '13 at 11:26
  • 1
    I am trying to include an xml file with my application. I've followed the instructions here, but if I need to reference the file in the code, what is the file path? – marky Feb 05 '15 at 20:15
  • 1
    Downvoted because it simply doesn't work. Followed these steps exactly in my project and no result whatsoever. – Russell Steen Feb 18 '15 at 19:25
  • 1
    It works only if you add the folder to the main project you publish from and set the build action to content! – Ade A Dec 07 '15 at 17:36
  • Thanks so much for your answer! – Christo S. Christov Jan 25 '16 at 22:00
  • 1
    Down voting because this doesn't solve situations where you have large complex folder structures where it would be entirely unreasonable to link all files. – SomeInternetGuy Feb 02 '16 at 19:08
  • I follow above process but my all files in datafiles folder and project exe indivisible execute so in this case my application is not running. – Pramod Gehlot May 16 '19 at 11:39
0

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.

Russell Steen
  • 6,494
  • 6
  • 38
  • 56
0

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.

HTTP 410
  • 17,300
  • 12
  • 76
  • 127