none
Problems setting up data in the Application Data directory RRS feed

  • Question

  • I have an application that I have written in C# 2.0 that I would like to deploy using a Setup and Deployment Project. The application uses data stored in a SQL 2005 .mdf file that I install along with it. Currently, I have the .mdf file installing into the Program Files\Application directory, which works fine for an administrator. What I would like to do is install the data into the User's Application Data folder, or, if they select All Users, into the All Users Application Data Folder. The problems that I've run into so far are:

    How can I tell if the user checked the All Users box. What is the Condition that I need to use to say that that box is checked, and what is the Condition to say that the Just Me box is checked?

    Can I set an entire folder to be installed or not with a Condition? I tried it, but it installed the data anyway.

    How can I get the path information as to where the data was installed so that I can write this for the application to know where to look?

    Thanks for any help you can give, I've been stuck on this installer all day.
    Tuesday, June 6, 2006 10:40 PM

Answers

  • This is the kind of thing to do:

    In File System on Target Machine,  you need to have the file in two folders:

    1. In Common Files Folder\Company name\App name

    The file (and not the folders) needs a condition (case sensitive) of:

    ALLUSERS=1

    This is the per machine condition.

    2. In User's Application Data Folder\Company name\App name

    The file (and not the folders) needs a condition (case sensitive) of:

    ALLUSERS<>1

    This is the per-user condition.

     

    You could also have a registry item that stores the ALLUSERS value. In the registry view, add an item and give it the value [ALLUSERS]. This will resolve at install time to the actual value.

    In your app, read this registry value and go to whichever folder it is. There is an equivalent to these folder names in Environment.SpecialFolder, I'm just not sure exactly which ones.  If I haven't got the folders exactly the way you want, try some others, but it's that ALLUSERS condition that's the key.

    Thursday, June 8, 2006 10:30 PM

All replies

  • This is the kind of thing to do:

    In File System on Target Machine,  you need to have the file in two folders:

    1. In Common Files Folder\Company name\App name

    The file (and not the folders) needs a condition (case sensitive) of:

    ALLUSERS=1

    This is the per machine condition.

    2. In User's Application Data Folder\Company name\App name

    The file (and not the folders) needs a condition (case sensitive) of:

    ALLUSERS<>1

    This is the per-user condition.

     

    You could also have a registry item that stores the ALLUSERS value. In the registry view, add an item and give it the value [ALLUSERS]. This will resolve at install time to the actual value.

    In your app, read this registry value and go to whichever folder it is. There is an equivalent to these folder names in Environment.SpecialFolder, I'm just not sure exactly which ones.  If I haven't got the folders exactly the way you want, try some others, but it's that ALLUSERS condition that's the key.

    Thursday, June 8, 2006 10:30 PM
  • The ALLUSERS=1 thing worked great, but is there any way to choose a directory of a single file based on a condition, rather than adding more than one copy? The file that I'm including is a database that is nearly 100 MB. I tried adding it twice, and it really does add it twice.

    I'm trying not to touch the registry, but your suggestion sounds like a good plan if it comes down to it. I wish there were a way to write an element into an xml file based on a condition. I might end up having to use a custom action, or just bite the bullet and pick up a copy of Installshield.
    Friday, June 9, 2006 10:27 PM
  • Turns out the problem that I thought that I was facing wasn't really the problem that I should have been facing. I am working towards having my application certified through VeriTest to get a Microsoft Competency. One of the requirements it to support all users installs, but reading it more closely, it says that you can force all users, OR give the option to install all users or current user. I've changed my installer to install with All Users forced, and everything is working great. Now I can just assume that the file I need will be in Documents and Settings\All Users\Application Data, and get on with what I was doing. Looks like I'll need to find out how to set the permissions on a new folder that I will be creating there, but that's a different issue.
    Tuesday, June 13, 2006 3:16 PM