How to prevent users from moving files - Programmer

This is a discussion on How to prevent users from moving files - Programmer ; I wrote an application that stores files in a windows diretory. How do I prevent users from moving the files to another directory? Thanks!...

+ Reply to Thread
Results 1 to 5 of 5

Thread: How to prevent users from moving files

  1. How to prevent users from moving files

    I wrote an application that stores files in a windows diretory. How do
    I prevent users from moving the files to another directory? Thanks!

  2. Re: How to prevent users from moving files

    jc wrote:
    > I wrote an application that stores files in a windows diretory.


    This is a bad idea, since only administrators can write to the Windows
    directory. Unless you have good reason, you should write your application so
    that it can be run by any user. Instead, you should store per-user files in
    the user's profile directory, per-computer files in the All Users profile
    directory, and per-user per-computer files in the user's Local Settings
    directory under their profile. See SHGetFolderPath and related functions.

    > How do
    > I prevent users from moving the files to another directory? Thanks!


    You can't. The user is in control of their own computer. You can apply
    permissions to files, but an administrator will always be able to override
    them.

    --
    Tim Robinson (MVP, Windows SDK)
    http://mobius.sourceforge.net/



  3. Re: How to prevent users from moving files

    On 12 Apr 2004 20:18:50 -0700, john_gsr@hotmail.com (jc) wrote:

    >I wrote an application that stores files in a windows diretory. How do
    >I prevent users from moving the files to another directory? Thanks!


    You don't want to do that.

    If the amount of data is small, and isn't needed by other apps, you
    might want to store it in the registry under a key for your
    application. in HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE as
    appropriate.

    --
    Sev

  4. Re: How to prevent users from moving files

    On Tue, 13 Apr 2004 19:50:29 -0400, Severian
    wrote:

    >On 12 Apr 2004 20:18:50 -0700, john_gsr@hotmail.com (jc) wrote:
    >
    >>I wrote an application that stores files in a windows diretory. How do
    >>I prevent users from moving the files to another directory? Thanks!


    I don't think you can completely keep all users from moving a file.
    But you can make it less easy. You will have to balance ease of use
    (for folks using your program legitimately), ease of programming (for
    you), and degree of protection (for the files). You should definitely
    make sure your program handles missing files gracefully (recreate
    files that can be recreated, post a message if more drastic action is
    required). If the main objective is to protect their contents, you can
    at least hide the files; you can also store data in them using some
    odd format, perhaps encryption.

    >
    >You don't want to do that.


    Well, I can think of two reasons:
    a) proprietary data
    b) keep users from breaking the app by moving files

    >
    >If the amount of data is small, and isn't needed by other apps, you
    >might want to store it in the registry under a key for your
    >application. in HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE as
    >appropriate.


    The registry is a shared resource, and I firmly believe in avoiding
    shared resources unless necessary. Data used by a single app should
    not be put in a shared resource.


    -----------------------------------------
    To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

    Robert E. Zaret, eMVP
    PenFact, Inc.
    500 Harrison Ave., Suite 3R
    Boston, MA 02118
    www.penfact.com

  5. Re: How to prevent users from moving files

    On Wed, 14 Apr 2004 08:40:56 -0400, r_z_aret@pen_fact.com wrote:

    >On Tue, 13 Apr 2004 19:50:29 -0400, Severian
    > wrote:
    >
    >>On 12 Apr 2004 20:18:50 -0700, john_gsr@hotmail.com (jc) wrote:
    >>
    >>>I wrote an application that stores files in a windows diretory. How do
    >>>I prevent users from moving the files to another directory? Thanks!

    >
    >I don't think you can completely keep all users from moving a file.
    >But you can make it less easy. You will have to balance ease of use
    >(for folks using your program legitimately), ease of programming (for
    >you), and degree of protection (for the files). You should definitely
    >make sure your program handles missing files gracefully (recreate
    >files that can be recreated, post a message if more drastic action is
    >required). If the main objective is to protect their contents, you can
    >at least hide the files; you can also store data in them using some
    >odd format, perhaps encryption.
    >
    >>
    >>You don't want to do that.

    >
    >Well, I can think of two reasons:
    >a) proprietary data
    >b) keep users from breaking the app by moving files


    Perhaps I should have been more explicit and said, "you don't want to
    depend on being able to do that."

    Hidden and difficult-to-access files seem to be most often created by
    trojans and viruses these days. An encrypted file would seem to me the
    best method for protecting data; however, since the application will
    have to decrypt it to use it, you can't prevent a determined user from
    accessing its contents.

    >>If the amount of data is small, and isn't needed by other apps, you
    >>might want to store it in the registry under a key for your
    >>application. in HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE as
    >>appropriate.

    >
    >The registry is a shared resource, and I firmly believe in avoiding
    >shared resources unless necessary. Data used by a single app should
    >not be put in a shared resource.


    I use the registry as little as possible (I prefer the ability to
    easily view and edit an INI-type file), but it is useful for
    user-specific configuration information.

    --
    Sev

+ Reply to Thread