Jump to content

Recommended Posts

well, im not sure why this doesn't work

$installserver=FILEFINDFIRSTFILE("C:\test-*.exe")
$packageserver=FILEFINDNEXTFILE($installserver)
FILECLOSE($installserver)
$dest=@DESKTOPDIR & "copytest-*.exe"

$FileCopy = _CopyWithProgress($packageserver, $dest, 5120)

and later

Func _CopyWithProgress($inSource, $inDest, $ChunkSize = 5120)
    $SourceFile = FileOpen($inSource, 16)
    If $SourceFile = -1 Then
        MsgBox(16, "Error", "Unable to open source file: " & $inSource)
        Exit
    EndIf
    
    $DestFile = FileOpen($inDest, 26)
    If $SourceFile = -1 Then
        MsgBox(16, "Error", "Unable to open destination file: " & $inDest)
        Exit
    EndIf

    $SourceSize = FileGetSize($inSource)

    $Chunks = $SourceSize / $ChunkSize

    ProgressOn("File Copy", "Copying...", "Source: " & $inSource & @LF & "Dest:  " & $inDest)

    For $i = 0 to $Chunks
        $Data = FileRead($SourceFile, $ChunkSize)
        FileWrite($DestFile, $Data)
        ProgressSet( (($i + 1) / $Chunks) * 100 )
    Next
    
    ProgressOff()
    FileClose($SourceFile)
    FileClose($DestFile)

    $DestSize = FileGetSize($inDest)

    If $SourceSize = $DestSize Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc

but it says it can't open the sorcefile. is there something special i have to do because its an .exe or does this func just not support wildcards?

thanks a lot

Link to post
Share on other sites
  • Moderators

redLabel,

What are the actual values of the 2 variables $inSource and $inDest that you pass to the _CopyWithProgress function?

You can find out by adding this line to the beginning of the function:

ConsoleWrite($inSource & " - " & $inDest & @CRLF)

and the values will appear in the lower SciTE window. :mellow:

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

it didn't output anything, but im quite sure the wildcards are being found because the msgbox does show and it locates the right file ie: "cannot open sourcefile 'test-25.exe'"

so, im not sure.

one other thing, if the file exists in the dest. then it will work, but doest overwirte it

Edited by redLabel
Link to post
Share on other sites
  • Moderators

redLabel,

Did the MsgBox really show the single quotes around the filename?

cannot open sourcefile 'test-25.exe'

Because if so, then there is little wonder that the function cannot find the file as AutoIt thinks they are part of the file name.

So we turn to how you get the $packageserver variable to pass to the function in the first place. We spoke about looking for files with FileFindFirst/NextFile - it is not how you should do it. Perhaps you might want to look again at the thread where we discussed it.

Could you please use a MsgBox to see what value you have in the $packageserver variable when you call the _CopyWithProgress function.

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

no there isn't '' around the $packageserver var, i did use a msgbox, and it is finding the proper value ie: test-25.exe

so i don't think it is a problem with the variable. it just seems to be with the fileopen (wildcard), in the mean time i will look up the older post

thank you for helping.

Link to post
Share on other sites

Maybe try something like:

$installserver=FILEFINDFIRSTFILE("C:\test-*.exe")
$packageserver=FILEFINDNEXTFILE($installserver)
FILECLOSE($installserver)
$dest=@DESKTOPDIR & "\copy"&$packageserver)

$FileCopy = _CopyWithProgress($packageserver, $dest, 5120)

I believe that @desktopdir does not have a trailing backslash which needs to be added between that and filename.

also, since the destination file name was simply your original file name plus copy at the front, I removed the wildcard by combining the word "copy" with the original filename variable.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to post
Share on other sites

Thanks much for your reply, but that didn't help any, it seems to have problems opening the file for reading after i make it a $var. if i name it specifically it works, but the file will be changing on a regular basis so i want to use a wildcard. so im not sure why once i change it to a wild card it fails to open. but im about ready to just say heck with it. lol. thanks for you help.

Link to post
Share on other sites

will your file to copy always be in the same directory? if so you could always use _fillisttoarray which accepts wildcards.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to post
Share on other sites
  • Developers

You are not making any sense.

What about you try to ask explicit questions in stead of the general " it doesn't work" ... you might get real help.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

why can't i do my above func (1st post) when i use a wild card for the file i want to copy.

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray("\\TESTSHARE\DIR\TEST", "TESTINSTALLER-*.exe", 1)

$FileCopy = _CopyWithProgress($FileList[1], "C:\"& $FileList, 5120)

If $FileCopy = 0 Then
    PROGRESSOFF()
    EXIT
Else
    MsgBox(16,"Copy Complete", "File Copy Failed.")
EndIf



Func _CopyWithProgress($inSource, $inDest, $ChunkSize = 5120)
    $SourceFile = FileOpen($inSource, 32)
    If $SourceFile = -1 Then
        MsgBox(16, "Error", "Unable to open source file: " & $inSource)
        Exit
    EndIf
    
    $DestFile = FileOpen($inDest, 26)
    If $SourceFile = -1 Then
        MsgBox(16, "Error", "Unable to open destination file: " & $inDest)
        Exit
    EndIf

    $SourceSize = FileGetSize($inSource)

    $Chunks = $SourceSize / $ChunkSize

    ProgressOn("File Copy", "Copying...", "Source: " & $inSource & @LF & "Dest:  " & $inDest)

    For $i = 0 to $Chunks
        $Data = FileRead($SourceFile, $ChunkSize)
        FileWrite($DestFile, $Data)
        ProgressSet( (($i + 1) / $Chunks) * 100 )
    Next
    
    FileClose($SourceFile)
    FileClose($DestFile)

    $DestSize = FileGetSize($inDest)

    If $SourceSize = $DestSize Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc

i can't get it to open the source file, i get my own msg box

$SourceFile = FileOpen($inSource, 32)
    If $SourceFile = -1 Then
        MsgBox(16, "Error", "Unable to open source file: " & $inSource)
        Exit
    EndIf

but this only happens when i use a wildcard for the .exe im copying. if i specify the exact folder and don't use $var for the $FileCopy, it works. if i use my method with the array, and msgbox out the result for $FileList[1] it find the right installer, so its not a problem with the $var's it just when they are = wildcards.

that is my specific ?.

sorry if im just missing something stupid.

Edited by redLabel
Link to post
Share on other sites

and tells me that it cannot open the source file: testinstaller-0.25.exe. it finds the file. the $vars are working and so is the array, but it can't open the file. and i cannot figure out why, is it because the file is "open" in some other way in my script? like i said if i don't use $vars and just give a dir and dest it works, but the msg box returns the correct value for the $var so it is finding it, but why can't it open it?

Edited by redLabel
Link to post
Share on other sites
  • Developers

and tells me that it cannot open the source file: testinstaller-0.25.exe. it finds the file. the $vars are working and so is the array, but it can't open the file. and i cannot figure out why, is it because the file is "open" in some other way in my script? like i said if i don't use $vars and just give a dir and dest it works, but the msg box returns the correct value for the $var so it is finding it, but why can't it open it?

Hey com'on... think!

why would it know where that file lives?

Where did you tell it its directory?

What do you think the directory is where it is trying to find it?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

HAHAHAHAH! I cannot believe im so stupid. i was getting the NAME of the installer, but couldn't open it because it still couldn't find it. thank you very much

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray("C:\", "test-*.exe", 1)

$FileCopy = _CopyWithProgress("C:\"& $FileList[1], "C:\test\"& $FileList[1], 5120)

thanks agian

Link to post
Share on other sites
  • Developers

HAHAHAHAH! I cannot believe im so stupid. i was getting the NAME of the installer, but couldn't open it because it still couldn't find it. thank you very much

Seriously: I have not told you anything new. Just reread this thread and see that you already got the answer in the very first reply from Melba23.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...