Jump to content

Weird and probably stupid problem with DirCopy


Recommended Posts

Hello everyone!

I'm writing an installer for my application that does a backup at a certain point. I'm writing AutoIT code since 3 years, and I really can't figure out why this line doesn't work.

DirCopy(@ScriptDir, @ScriptDir & "\MWBackup", 1)

I feel REALLY stupid, that's so simple! :S

For some reason it creates the Directory but it doesn't copy files in it. Can you help me please? It works as intended with ANY other source folder.

Edited by Kingpix
Link to comment
Share on other sites

I guess the target directory is created first and then the function tries to copy that into itself...

#include <File.au3>
Local $s_TempDir = _TempFile(@TempDir, "~", "", 7)
DirCopy(@ScriptDir, $s_TempDir & "\", 1)
DirRemove($s_TempDir & "\MWBackup\", 1) ; to avoid recursion during backup (taking a backup of the old backup)
DirCopy($s_TempDir & "\", @ScriptDir & "\MWBackup\", 1)
DirRemove($s_TempDir, 1)
Link to comment
Share on other sites

Thanks for the input, but I realized there is another problem.

The @ScriptDir macro returns "E:", which is the root of the E HDD. And that's correct, but after doing some research I found out that DirCopy doesn't work with HDD roots. :(

Link to comment
Share on other sites

Even though, it seems weird to copy something inside itself.

Edit: If this last does not work you can do a recursive copy, there may be some examples on the forum (e.g: _RecFileListToArray combined with FileCopy) ;).

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...