Keithw Posted November 13, 2015 Share Posted November 13, 2015 (edited) Hey folks, I am using the FileCopy command, which does what I want, but the function returns 0. The funny thing is that it was returning 1 yesterday. I reverted my changes, but it still returns 0 Local $bCopyCheck = FileCopy($sComputerDir & $sAdobeFolder, @ScriptDir, $FC_OVERWRITE) If ($bCopyCheck = 0) Then GUICtrlSetData($Tab2OutputLabel, "Failed to Copy Key File") MsgBox(0,"Test", "FileCopy Func Returned " & $bCopyCheck) Return Else GUICtrlSetData($Tab2OutputLabel, "So far so good!") FileChangeDir(@ScriptDir) Local $bFHandle = FileOpen("*.swi") Edited November 13, 2015 by Keithw Link to comment Share on other sites More sharing options...
Developers Jos Posted November 13, 2015 Developers Share Posted November 13, 2015 (edited) Well, when a 0 is returned it will not have been fully successful. There is not enough information to really be able to help you.Jos Edited November 13, 2015 by Jos 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...
Keithw Posted November 13, 2015 Author Share Posted November 13, 2015 Well, I added a check to see the value of @error and @extended macro's and recompiled and now the function is returning 1.... Well, when a 0 is returned it will not have been fully successful. There is not enough information to really be able to help you.JosRegardless if the function returns 1 or 0 it copies the file over. :| Link to comment Share on other sites More sharing options...
Developers Jos Posted November 13, 2015 Developers Share Posted November 13, 2015 I could be copying a couple of files and then hitting an issue and failing, hence my comment of "not enough info".Jos 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...
Keithw Posted November 13, 2015 Author Share Posted November 13, 2015 Well, I won't beat a dead horse. One more question(I know you answer a lot of them here ). After the file is copied, I need to open it with FileOpen()(which is returning -1). The name of the file is not foreknown so I'm using the file extension:GUICtrlSetData($Tab2OutputLabel, "So far so good!") FileChangeDir(@ScriptDir) Local $bFHandle = FileOpen("*.swi") If $bFHandle = -1 Then GUICtrlSetData($Tab2OutputLabel,"Unable to open key file") Return Else GUICtrlSetData($Tab2OutputLabel, "Keyfile Opened!") EndIfThe full file extension is ".swidtag". I'm not sure if I'm using the wildcard correctly from the example above, but I think this should be searching for any files in the current active directory with ".swi" in its extension. I saw StringRegExp() but I'm not sure how to get a list of file names in a directory so I could sort through an array with this built-in function. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 13, 2015 Developers Share Posted November 13, 2015 Well, I won't beat a dead horse. I would keep on beating till it works properly and returning a 1 as you have no means to check success now. One more question(I know you answer a lot of them here ). After the file is copied, I need to open it with FileOpen()(which is returning -1). The name of the file is not foreknown so I'm using the file extension:The full file extension is ".swidtag". I'm not sure if I'm using the wildcard correctly from the example above, but I think this should be searching for any files in the current active directory with ".swi" in its extension. You obviously can't open a filename with a wildcard, so need to use FileFindFirstFile/FileFindNextFile to retrieve the full filename first after which you can open it.Jos Keithw 1 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...
Keithw Posted November 13, 2015 Author Share Posted November 13, 2015 I would keep on beating till it works properly and returning a 1 as you have no means to check success now. You obviously can't open a filename with a wildcard, so need to use FileFindFirstFile/FileFindNextFile to retrieve the full filename first after which you can open it.Jos Then why does it say that wildcards are accepted? FileCopy Link to comment Share on other sites More sharing options...
Developers Jos Posted November 13, 2015 Developers Share Posted November 13, 2015 (edited) That statement was about FileOpen(), not FileCopy!Jos To re-iterate:Your FileCopy() likely returns 0 because one of the files that qualifies your provoded filemask is unable to be copied!You FileOpen needs the exact filename which can be retrieved with FileFindFirstFile/FileFindNextFile.All Clear? Edited November 13, 2015 by Jos 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...
Keithw Posted November 13, 2015 Author Share Posted November 13, 2015 (edited) That statement was about FileOpen(), not FileCopy!Jos To re-iterate:Your FileCopy() likely returns 0 because one of the files that qualifies your provoded filemask is unable to be copied!You FileOpen needs the exact filename which can be retrieved with FileFindFirstFile/FileFindNextFile.All Clear? Okay, well I got it working with FileFind. So now my script works all fine. There is only 1 file in the directory I'm copying from and I've made sure there are no hidden files in that folder as well. I am copying this file through the network, so what I do believe is happening is that another program is accessing this file during my FileCopy and for some weird reason FileCopy copies the file but returns failed. Thanks for all your responses. Local $sFileName = "" $sFileName = FileFindNextFile($hSearch) ;MsgBox(0, "", "File: " & $sFileName) ;Close the search handle FileClose($hSearch) Local $bFHandle = FileOpen($sFileName) If $bFHandle = -1 Then GUICtrlSetData($Tab2OutputLabel,"Unable to open key file") MsgBox(0,"Error","FileOpen(): " & $bFHandle & @CRLF & "@Error: " & @CRLF & @error & @CRLF & "Extended: " & @extended) Return Edited November 13, 2015 by Keithw 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