CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Copy File Issue

  1. #1
    Join Date
    Oct 2011
    Posts
    97

    Copy File Issue

    Hi guys, I'm hoping for some help with an issue we're having. It started out as what we thought to be an issue with our program, but we're pretty sure that it's an issue with Windows now. Basically, here's what happens.

    We have a program that uses a database in a .db file. For our scenario, the .db file is in the program files directory along with the .exe for the program. Opening the DB and editing it works fine. Changes are saved. But, if we attempt to copy the DB to a different path, changes are lost. Take this scenario, which is the scenario of our customer who's having this issue:

    The program was installed on April 15. The DB was put in a folder called Databases in the program files directory. She's been using the program without issue since April 15. Today, she decides to backup her DB. She copies the .db file from the Database folder to her Documents folder. Upon opening the backup, her data since April 15 has been lost. If she opens the .db file in the Database folder in the program files directory, her data is there. If she opens up the backup up copy, the data is gone.

    It's almost like Windows is copying a cached version of her file and not the current version. (Is that even possible?) And this only happens when the file is located in the application directory. If the DB file started out on the Desktop, this problem doesn't happen.

    My boss was able to reproduce the issue on his PC. I wasn't. We're currently trying to track this thing down, as our customer needs to backup her DB. Does anybody know of ANYTHING that could cause an issue like this? I've been using Windows 7 extensively for the past year, but I'm completely flabbergasted.

    The only thing that I could think of is that she's on a school PC, so with the elevated permissions, maybe she doesn't have access or something. Other than that, I could really use some help. And I appreciate any help given.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Copy File Issue

    By default the program files directory is read only (only Administrator can write to it).
    Fo normal user Windows 7 creates a virtual folder with a copy of your DB and writes to it. Try to search fo it (but don't forget to show all system and hidden files and folders!)
    Victor Nijegorodov

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: Copy File Issue

    So, you're able to copy a database from the Program Files directory...the database in that folder stays intact...but the newly copied database is empty? That doesn't make any sense at all. This can't even be a permissions issue...you're reading from, not writing. If even reading was denied, then a shadow copy wouldn't even appear in the new destination folder.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Oct 2011
    Posts
    97

    Re: Copy File Issue

    Quote Originally Posted by VictorN View Post
    By default the program files directory is read only (only Administrator can write to it).
    Fo normal user Windows 7 creates a virtual folder with a copy of your DB and writes to it. Try to search fo it (but don't forget to show all system and hidden files and folders!)
    This has to be it. I read up a bit on it, and it's apparently a safety mechanism so that one particular user can't corrupt a program for all users.

    I'm going to attempt to work with it a bit and see if I can't figure this out. I'll let you know when I've solved it.

    Thanks again.

  5. #5
    Join Date
    Oct 2011
    Posts
    97

    Re: Copy File Issue

    That was indeed the issue. Thank you Victor. For anybody else wondering, there's a good article about developing with UAC.

    http://windowsteamblog.com/windows/b...direction.aspx

    We were able to help the customer and we're now going to make sure that our apps are UAC aware (something that I've wanted to do for a long time now). Looks like it's time to finally bring our app up to speed with a feature that came out in 2006.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured