Sign in to follow this  
Followers 0
ilko

FileCopy bug or expected behaviour?

1 post in this topic

#1 ·  Posted (edited)

#Include <WinAPI.au3>
_WinAPI_GetLastErrorMessage()
$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 3.3.6.1.

 

Edit:

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  
Followers 0