none
Setup project files

    Question

  • I need to create a deployment project for my application and I have files that are in my visual studio project that are in my bin folder and I serialize settings to them when my application is running.

    However when I copy my project to the setup project, all these files are then installed in the program files folder with my program and the program crashes whilst writing to them because the application doesn't presumably have write permissions in this folder.

    When creating a setup project where do I place these files that would normally be in my bin/debug folder in visual studio project in order to write to them when the application is installed.

    Im sorry I haven't used a setup project before and I would appreciate it if someone could point me to a page or something to help me.

    Sunday, May 03, 2009 12:59 AM

Answers

  • I solved the problem in the end by using the special folder by right clicking on "File System On Target Machine" and selected "add Special folder" and then "User's Application Data Folder" and dropped my files into there.

    Then in my code I added something like this and it worked when it installed!

     

    string writeFolder = "";

    writeFolder =

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\";

    #if

     

    DEBUG

    {

    writeFolder =

    "";

    }

    #endif

     

    //Settings file to read

    mnuControllerSettings.SetFile(writeFolder + SETTINGS_FILE);...........

    • Marked as answer by Drnly Sunday, May 03, 2009 11:08 PM
    Sunday, May 03, 2009 11:08 PM

All replies

  • I don't know what the terminology is in a setup project (my expertise is in ClickOnce), but here is what I *do* know.

    In Windows Vista, there are only a couple of places where you can write data. One is MyDocuments, and the other is LocalApplicationData. This is how you get it using C#:

    string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
    I don't know what the corresponding variagble is in a setup project, but hopefully there is one.

    In ClickOnce, we have our application copy the files over there the first time the user runs the application, and then we update them after that, but never replace them when a new version is installed. You might consider that idea as well.

    RobinDotNet
    Click here to visit my ClickOnce blog!
    Sunday, May 03, 2009 8:36 PM
    Moderator
  • Oh ok thanks, I thought there must be a way to copy it into a writable application folder directly from the setup project however I guess I will have to create them when I first run the program instead and will have to change the file path in my program to lead to the local application data directory.
    Sunday, May 03, 2009 9:43 PM
  • I solved the problem in the end by using the special folder by right clicking on "File System On Target Machine" and selected "add Special folder" and then "User's Application Data Folder" and dropped my files into there.

    Then in my code I added something like this and it worked when it installed!

     

    string writeFolder = "";

    writeFolder =

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\";

    #if

     

    DEBUG

    {

    writeFolder =

    "";

    }

    #endif

     

    //Settings file to read

    mnuControllerSettings.SetFile(writeFolder + SETTINGS_FILE);...........

    • Marked as answer by Drnly Sunday, May 03, 2009 11:08 PM
    Sunday, May 03, 2009 11:08 PM
  • There you go. But you might want to actually create a folder under LocalApplicationData and put the files in the folder. We create a folder with our company name. This way, it's obvious who those files belong to in case the user starts snooping around.

    RobinDotNet
    Click here to visit my ClickOnce blog!
    Monday, May 04, 2009 4:33 AM
    Moderator
  • What file do you put ths in?
    Ivan
    Wednesday, June 22, 2011 7:47 PM