Mar-13-2019, 10:04 AM
Hello,
I am building some automated tests including install/uninstall of an app. I need to build a small back-up file system for a file.
I have a file called User.gdh inside this folder:
- C:\ProgramData\MyProgram\Database , so basically the full path is this C:\ProgramData\MyProgram\Database\User.gdh
I want to create a copy of this file inside the same folder that will be called User.gdh.testcopy.
Now if User.gdh.testcopy exists in this folder, I want to copy it over User.gdh.
If User.gdh.testcopy does not exists in folder(this will happen only after a freshInstall of my tested program), I want to copy it from User.gdh and name with test copy inside the same folder.
I've tried this:
What would be the best solution here?
I am building some automated tests including install/uninstall of an app. I need to build a small back-up file system for a file.
I have a file called User.gdh inside this folder:
- C:\ProgramData\MyProgram\Database , so basically the full path is this C:\ProgramData\MyProgram\Database\User.gdh
I want to create a copy of this file inside the same folder that will be called User.gdh.testcopy.
Now if User.gdh.testcopy exists in this folder, I want to copy it over User.gdh.
If User.gdh.testcopy does not exists in folder(this will happen only after a freshInstall of my tested program), I want to copy it from User.gdh and name with test copy inside the same folder.
I've tried this:
def userGdhBackup(): userGdhPath = C:\ProgramData\MyProgram\Database\User.gdh userGdhTestCopy = C:\ProgramData\MyProgram\Database\User.gdh.testcopy if os.path.isfile(userGdhTestCopy): shutil.copy(userGdhTestCopy,userGdhPath) else: shutil.move(userGdhPath,userGdhTestCopy)I guess this is not quite good and I am also getting "Permission denied error"
What would be the best solution here?