Jump to content

Recommended Posts

Posted (edited)

Hi guys,

Maybe it's a stupid error, but really I can not find a solution.

I have a txt with path of files, example:

C:\Documents and Settings\Windows Xp\Desktop\autoit-v3-setup.exe
C:\Documents and Settings\Windows Xp\Desktop\File.au3
C:\Documents and Settings\Windows Xp\Desktop\RecFileListToArray.au3
C:\Documents and Settings\Windows Xp\Desktop\SciTE4AutoIt3.exe

The last line is empty. Now i want to copy the file and i have make this:

$Log = FileRead(@WorkingDir & "\Final.txt")
$aArray = StringSplit($Log, @LF)
For $i = 1 To $aArray[0] -1 ; - 1 remove last empty line
;~ MsgBox(0,0, $aArray[$i])
FileCopy($aArray[$i], "C:\")
Next

With MsgBox or ConsoleWrite i see the full path, but the FileCopy not work.

Some advice?

Thanks

Edited by johnmcloud
Posted

Hello johnmcloud,

check the returncode of the FileCopy function.

Maybe you're missing the right to copy files directly to C:?

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Posted

Which OS are you running?

Try adding a "#RequireAdmin" on top of your script.

As far as I know, Vista and later require administrative rights to write directly to the C: drive

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Posted (edited)

@hanness08

Check the first post and the path in the code ;)

It's XP

@forumer100

Not work:

#RequireAdmin ; hanness08

$Log = FileRead(@WorkingDir & "Final.txt")
$aArray = StringSplit($Log, @LF)
For $i = 1 To $aArray[0] -1 ; - 1 remove last empty line
ConsoleWrite($aArray[$i])
FileCopy("C:Documents and SettingsWindows XpDesktopautoit-v3-setup.exe", @WorkingDir & "Test") ; This Work, also without the #RequireAdmin
FileCopy('"' & $aArray[$i] & '"', @WorkingDir & "Test") ; This not, WTF!
Next

Please someone test it ;)

Edited by johnmcloud
Posted (edited)

I assume that StringSplit will leave some characters (CR) in the filename which will cause the problem.

I was bored looking to Dali everytime.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Mmm you have right:

#include <File.au3>
$Log = FileRead(@WorkingDir & "Final.txt")
$aArray = StringSplit($Log, @CR)
_FileWriteFromArray(@WorkingDir & "Test.txt",$aArray)

This is the output:

Posted Image

#include <File.au3>
$Log = FileRead(@WorkingDir & "Final.txt")
$aArray = StringSplit($Log, @CRLF)
_FileWriteFromArray(@WorkingDir & "Test.txt",$aArray)

This is the output:

Posted Image

Suggestion?

Edited by johnmcloud

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
×
×
  • Create New...