Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Click once deployed application, where the XDocument.Save will be saved?
 

Click once deployed application, where the XDocument.Save will be saved?

Hello,

I am creating a XML document and saving using XDocument.Save. When I run in debug mode from the VS2008, it is saved in my current application debug directory. When deployed using click once, where it will be saved?

  • Moved byRoahn LuoMSFTThursday, August 20, 2009 2:34 AMnot a Visual Studio Debugger issue. (From:Visual Studio Debugger)
  •  
Basha  Wednesday, August 19, 2009 8:25 PM

If you want your application to store the file outside the deployment, the recommended location is LocalApplicationData.

You should create a folder under that directory and put your file(s) there. You can always create it or copy it over there the first time, then always update that version just by checking to see if the directory and file exist.

Here's how toget the file path for LocalApplicationData:

string userFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "myAppName");
If (!Directory.Exists(userFilePath))
Directory.Create(userFilePath);
string myFile = Path.Combine(userFilePath, "myfilename.txt");
if (!File.Exists(myFile))
File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "myfilename.txt"), myFile);

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 31, 2009 3:06 AM
Hello Basha,

I'm moving this thread from the base "Visual Studio Debugger" forum to "Click once Setup & Deployment" forum. There are more experts there to provide help for Clickonce issues.

Best regards,
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have any feedback, please tell us.
Welcome to the All-In-One Code Framework!
Roahn Luo  Thursday, August 20, 2009 2:33 AM


If you deploy a ClickOnce application that does as you have indicated, it will probably save it in the same folder as the primary assembly, which can be found using System.Windows.Forms.Application.StartupPath. Note that when you upgrade, it creates all new folders, and will leave this file behind. If that doesn't work for you, post back and I'll share where you *should* put it in order to retain it between versions.

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Thursday, August 20, 2009 5:20 AM
Thanks for the answer.

But I do not see the file created in that folder. The path where I am looking is \\server name\iis website folder\application folder\application files\folders for each version\

I do not see the file there for the version I am running.

When I run in debug mode it is the folder where it should be ...\bin\debug

Can I force it to write to a particular folder in the iis website folder?

Basha  Thursday, August 20, 2009 3:21 PM

I don't think I'm understanding something here.

I thought from your first post that you meant that the ClickOnce application is building the file. Is that not true? Are you building it with something else and putting it in the [exe] folder so you can include it in the deployment?

If that's the case, I could take a copy of the file and add it to the project properly. Set "build action" = "content" and "copy to output directory" = "copy always".

Then go into the Application Files dialog and find the file, and change it from "Data" to "Include" or "Include(required"). By default, ClickOnce deploys xml files as data, and they go into the ApplicationDeployment directory.

Now the file will be included in the deployment, and be in rhe same folder as the exe file.

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Friday, August 21, 2009 1:19 AM

The file is created when in debug mode.

I found the answer why the file is no more to find. Since in click once, if you deply using 'Available only online' optionthe temp folder created for executing in the executing machine is removed when you exit the application.

So all the files are removed along with this. Including the ones you created through the program I think. Either it needs to be added to afolder outside the executing environment or copied toanother location before exiting the application!

basha
Basha  Tuesday, August 25, 2009 6:26 PM
Hello Basha,

In addition, we can also try to use the Process Monitor to detect where the application stored the files.

http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

Feel free to post here if you had any difficult to use Process Monitor.

Thanks,
Rong-Chun Zhang
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Thursday, August 27, 2009 10:26 AM

If you want your application to store the file outside the deployment, the recommended location is LocalApplicationData.

You should create a folder under that directory and put your file(s) there. You can always create it or copy it over there the first time, then always update that version just by checking to see if the directory and file exist.

Here's how toget the file path for LocalApplicationData:

string userFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "myAppName");
If (!Directory.Exists(userFilePath))
Directory.Create(userFilePath);
string myFile = Path.Combine(userFilePath, "myfilename.txt");
if (!File.Exists(myFile))
File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "myfilename.txt"), myFile);

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 31, 2009 3:06 AM

You can use google to search for other answers

Custom Search

More Threads

• Get the condition result from setup
• How to create MSI with feature like update and logging
• How to work with version nr in winform applications
• File associations - again
• Customizing Deployment Setup
• Uninstall SQL Server 2005 Express during uninstallation of custom software
• WebBrowser's .Navigate method crashes
• Regarding Crystal Report Files
• Adding offline NET Framework 3.5 (DotNetFxClient35.exe) to the VS2008 installation?
• Passing arguments through setup.exe