Necromorph Posted February 26, 2010 Share Posted February 26, 2010 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 expandcollapse popupFunc _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 comment Share on other sites More sharing options...
Moderators Melba23 Posted February 26, 2010 Moderators Share Posted February 26, 2010 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 (edited) 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 February 26, 2010 by redLabel Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 26, 2010 Moderators Share Posted February 26, 2010 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 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 comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 still not having any luck, and i don't get it. becuase my msgbox for the error "cannot open source file: $installerpackage", returns the right name of the installer, so there $var are fine, it just won't open it if its a wild card. Link to comment Share on other sites More sharing options...
kaotkbliss Posted February 26, 2010 Share Posted February 26, 2010 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 gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 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 comment Share on other sites More sharing options...
kaotkbliss Posted February 26, 2010 Share Posted February 26, 2010 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 gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 yeah, it will always copy to the desktop, and it will always be copying from the same place as well. i will look into it. ive never used that, so i will see if i can get it to work. thanks. Link to comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 well, bad news, i got the array to work, i can msgbox out the right installer, but same thing. says it cannot read from it, i a have about had it. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 26, 2010 Developers Share Posted February 26, 2010 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 comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 (edited) why can't i do my above func (1st post) when i use a wild card for the file i want to copy. expandcollapse popup#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 February 26, 2010 by redLabel Link to comment Share on other sites More sharing options...
Developers Jos Posted February 26, 2010 Developers Share Posted February 26, 2010 .. and what exactly does your msgbox tell you? 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 comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 (edited) 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 February 26, 2010 by redLabel Link to comment Share on other sites More sharing options...
Developers Jos Posted February 26, 2010 Developers Share Posted February 26, 2010 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 comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 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 comment Share on other sites More sharing options...
Developers Jos Posted February 26, 2010 Developers Share Posted February 26, 2010 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 muchSeriously: 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 comment Share on other sites More sharing options...
Necromorph Posted February 26, 2010 Author Share Posted February 26, 2010 yeah, im sure that this was dragged out much much longer then needed. but when it would msgbox out the right name of the .exe i was looking for, i thought for sure the code was right, so sorry again for wasting time. and thanks for helping me solve the issue. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now