Jump to content
Sign in to follow this  

FileCopy bug or expected behaviour?

Recommended Posts


#Include <WinAPI.au3>
$a = FileCopy("D:\flp.img", "H:\boot\bcd", 8)
ConsoleWrite($a & @CRLF & _WinAPI_GetLastErrorMessage() & @CRLF)

If a file H:boot already exists, FileCopy fails with "The directory name is invalid.", the directory h:boot is not created and surely the file is not copied. If the file h:boot is renamed or deleted, everything goes fine.

Is this expected behaviour or a bug, or I am missing something obvious? Why a file with the same name as the folder which has to be created exists prevents FileCopy from creating that folder and copying the file?

FileCopy("D:\flp.img", "H:\boot\"

This fails the same way.

In addition, is it correct to use a file as destination? Documentation is not 100% clear, and it seems to work.

Using AutoIt



Ahh, never mind, Windows....

Explorer also won't let me create a directory "boot" if a file with the same name already exists in that destination, Windows 7 x64.

Edited by ilko

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.