1
  1. I have an Excel addin application which I developed with C# and I published to a network location using ClickOnce from VS2010.

  2. The application assumes that all the xml files that I use in it are in the same folder as the application itself.

  3. But when the user installs my app using ClickOnce

the application files are copied into one folder ( C:\Users\myUser\AppData\Local\Apps\2.0\4THJAWJK.HYG\5N2YL58D.X55\ical..vsto_d6a691f9c1918311_0006.0000_ac7a074687bf4c5e )

the Data files as xml are copied into other location ( C:\Users\myUser\AppData\Local\Apps\2.0\4THJAWJK.HYG\5N2YL58D.X55\ical...dll_d6a691f9c1918311_0006.0000_none_a70d8116aa98d903 )

The question is do I have any configuration in visual studio which will force all the files to be copied into one folder after the install or is there any other way to do it?

Thank you.

Sergey Kucher
  • 4,140
  • 5
  • 29
  • 47

1 Answers1

1

I think there are a couple solutions to your problem depending on the intent of your XML file.

Option #1 If you are desiring to copy and XML file to the root install directory of your application each time that you publish the application, all you need to do is open your projects Properties dialog, go to the Publish tab and open the "Application Files..." dialog.

By default, when an XML file is included with a project, ClickOnce specifies that these files should be published as a "Data File" (under the Publish Status option.)

Change the Publish Status to Include, and the XML file will be copied to your installation folder, instead of the data folder.

Option #2 If you are looking to create an XML file that will be used for caching user-specific settings which should persist across application updates, I recommend outputing a default XML file as mentioned in step #1, however, when the application starts check to see if the XML file is in a settings folder that you have created within the User's Profile folder. The first time that the application launches you will also need to check and see if your folder exists within the User's Profile. If not, create it and copy your default XML file.

Within your application, you can obtain the user's data folder with the following line of code:

string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile);

You should have full access to the user's profile folder for creation of folders and copying content, so you should have to worry about admin or special priviledges.

RLH
  • 15,230
  • 22
  • 98
  • 182
  • About you first solution : I cant see the see the Application Files dialog what could be the problem , using vs2010 professional – Sergey Kucher Jun 16 '11 at 20:53
  • Option two Is the only one that office addins permit , thank you! – Sergey Kucher Jun 17 '11 at 08:08
  • Ah, sorry about that. I've never worked with office add-ins, however, I have published numerous ClickOnce applications. – RLH Jun 17 '11 at 12:43
  • 1
    There is no Application Files dialog for VSTO apps, and it will only deploy XML as data files. You can pick them up programmatically from the ApplicationDeployment.DataDirectory location and copy them back to the same folder as your exe if you need them there. – RobinDotNet Jul 07 '11 at 23:55