Jump to content
Sign in to follow this  
Simpel

[Solved] Failing FileCopy creates hidden file

Recommended Posts

Simpel

Hi,

I'm using following code:

Global $FileName = "test.log"
Global $copyPath = "H:\Temp\Test\Log\"

FileCopy(@ScriptDir & "\" & $FileName,$copyPath)

If @error Then
    _DebugOut("Copy failed: " & $copyPath)
Else

    _DebugOut("Copied to: " & $copyPath)
EndIf

If folder "Log" is not existing then FileCopy creates a hidden file "Log" at "H:TempTest" with 1KB. 

Second I'll get the message in my debug file "Copied to: H:TempTestLog". But it's not true.

Any suggestions?

I tried an asterisk at the end of my $copyPath as it is suggested >here.

FileCopy(@ScriptDir & "\" & $FileName,$copyPath & "*")

Now there will be no hidden file but @error leads always to "Copied to: H:TempTestLog".

What's wrong?

Regards Simpel

Edited by Simpel
solved

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites
JLogan3o13

Per the help file:

The destination directory must already exist, except using with flag value $FC_CREATEPATH (8).
For instance the combined flag $FC_OVERWRITE (1) + $FC_CREATEPATH (8) overwrites the target file and pre-checks for the destination directory structure and if it doesn't exist creates it automatically.

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Simpel

Thanks.

I know. But it shouldn't try to create that folder.

So I decided to take the default, what is '0' or left blank.

It's not a solution for me.

Simpel


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites
Simpel

Found out myself:

$msg = FileCopy(@ScriptDir & "\" & $FileName,$copyPath & "*")

If $msg = "1" Then
    _DebugOut("Copied to: " & $copyPath)
Else
    _DebugOut("Copy failed: " & $copyPath)
EndIf

Now no hidden file is created while failing and the debug messages will be correct.

Regards Simpel

P.S. Caution: the $copyPath has to end with a "".


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

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  

×