Zithen Posted July 19, 2005 Share Posted July 19, 2005 i dont know what i am missing, i have tried many many ways to do this but all are failing at the same spot, the fileopen is returning -1. it will find the first file correctly but wont open. anyone have any insight? heres a snipet of code ;maps v: for pulling files DriveMapAdd("V:","\\server\dir\") ; Shows the filenames of all files in the current directory $rootpath= "V:\logs\" $remotepath="N:\logxp\" $searchpath= $rootpath & "*.txt" $linesread = 0 $begin = TimerInit() $numfiles = 0 $read = 0 $skip = 0 $search = FileFindFirstFile("$rootpath") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $numfiles = $Numfiles +1 $filename = FileFindNextFile($search) ;If @error Then ExitLoop $file = FileOpen($filename, 0) ;this shows the first file name but $file returns -1 everytime ;MsgBox(0,"err",$filename & @cr & $file) ; Check if file opened for reading OK If $file == -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Link to comment Share on other sites More sharing options...
w0uter Posted July 19, 2005 Share Posted July 19, 2005 $search = FileFindFirstFile("$rootpath") isnt right. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Josbe Posted July 19, 2005 Share Posted July 19, 2005 ...the first I saw: ... $search = FileFindFirstFile("$rootpath") ... (no quotes) ... $search = FileFindFirstFile($rootpath) ... (try again) AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
/dev/null Posted July 19, 2005 Share Posted July 19, 2005 i dont know what i am missing, i have tried many many ways to do this but all are failing at the same spot, the fileopen is returning -1. it will find the first file correctly but wont open. anyone have any insight?It's not fileopen() but findfilefirstfile() that fails!Wrong:$search = FileFindFirstFile("$rootpath") Correct:$search = FileFindFirstFile($rootpath) CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
seandisanti Posted July 19, 2005 Share Posted July 19, 2005 (edited) It's not fileopen() but findfilefirstfile() that fails!Wrong:$search = FileFindFirstFile("$rootpath") Correct:$search = FileFindFirstFile($rootpath) CheersKurt<{POST_SNAPBACK}>actually, i think this is the way to go...$search = FileFindFirstFile($searchpath)since $searchpath is given the file mask... Edited July 19, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
Zithen Posted July 19, 2005 Author Share Posted July 19, 2005 aye...without quotes failed also, i have tried even writing the hole path out and that failed as well. the time it works is when i have the search field empty and run the file within the logs directory, but alas i cant keep that file there due to other people needed to run it Link to comment Share on other sites More sharing options...
Developers Jos Posted July 19, 2005 Developers Share Posted July 19, 2005 aye...without quotes failed also, i have tried even writing the hole path out and that failed as well. the time it works is when i have the search field empty and run the file within the logs directory, but alas i cant keep that file there due to other people needed to run it<{POST_SNAPBACK}>the $filename variable will only contain the filename but is missing the whole path.try:$file = FileOpen($rootpath & $filename, 0) 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...
seandisanti Posted July 19, 2005 Share Posted July 19, 2005 the $filename variable will only contain the filename but is missing the whole path.try:$file = FileOpen($rootpath & $filename, 0)<{POST_SNAPBACK}> here's corrected code... tested it myself... i changed the filefindfirstfile() per my suggestion above, and changed the assignment to $filename to include the path...expandcollapse popup;maps v: for pulling files ;DriveMapAdd("V:","\\server\dir\") ; Shows the filenames of all files in the current directory $rootpath= "S:\AGNTSTATS\" ;$remotepath="N:\logxp\" $searchpath= $rootpath & "*.csv" $linesread = 0 $begin = TimerInit() $numfiles = 0 $read = 0 $skip = 0 $search = FileFindFirstFile($searchpath) ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $numfiles = $Numfiles +1 $filename = $rootpath & FileFindNextFile($search) MsgBox(0,"filename",$filename) ;If @error Then ExitLoop $file = FileOpen($filename, 0) ;this shows the first file name but $file returns -1 everytime ;MsgBox(0,"err",$filename & @cr & $file) ; Check if file opened for reading OK If $file == -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf WEndhad to change paths to paths i actually had to test... Link to comment Share on other sites More sharing options...
/dev/null Posted July 19, 2005 Share Posted July 19, 2005 actually, i think this is the way to go...$search = FileFindFirstFile($searchpath)correct!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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