hot202 Posted August 26, 2009 Share Posted August 26, 2009 Hey i know how 2 make it so some 1 can search 4 a folder with FileSelectFolder but how would i make it so they cant select the folder unless it had a file in it like (thisNeedsToBeInFolder.exe) and if it dont have that in it they cant select it? thanks heaps guys 4 all the help Link to comment Share on other sites More sharing options...
Andreik Posted August 26, 2009 Share Posted August 26, 2009 I don't know if you can do this so simple, but an easy way is this: _FileSelectFolder("Select","","calc.exe") Func _FileSelectFolder($DialogText,$RootDir,$FileNeedExists) While True Local $DIR = FileSelectFolder($DialogText,$RootDir) If Not @error Then If FileExists($DIR & "\" & $FileNeedExists) Then ExitLoop EndIf WEnd Return $DIR EndFunc If you select an folder without calc.exe the function will ask again for folder. If you select system32 dir or another folder that contain a file with name calc.exe the loop will end. Hope it help you this example. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
hot202 Posted August 26, 2009 Author Share Posted August 26, 2009 sweet thats kinda what im looking 4 thanks heaps. So u cant have a msg box saying calc.exe isnt in this folder please select again. Link to comment Share on other sites More sharing options...
Andreik Posted August 26, 2009 Share Posted August 26, 2009 _FileSelectFolder("Select","","calc.exe") Func _FileSelectFolder($DialogText,$RootDir,$FileNeedExists) While True Local $DIR = FileSelectFolder($DialogText,$RootDir) If Not @error Then If FileExists($DIR & "\" & $FileNeedExists) Then ExitLoop Else MsgBox(0x10,"Error","File " & $FileNeedExists & " doesn't exist is this folder." & @CRLF & "Please try again.") EndIf Else ExitLoop EndIf WEnd Return $DIR EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
hot202 Posted August 26, 2009 Author Share Posted August 26, 2009 sweet thanks and if i have it save that location to a ini what line do i put the ini IniWrite("C:\Setup.ini", "Location", "dir", $DIR) Link to comment Share on other sites More sharing options...
hot202 Posted August 26, 2009 Author Share Posted August 26, 2009 is that the right place to put my iniWrite? am i ment to put Then at the end of it? _FileSelectFolder("Select","","calc.exe") Func _FileSelectFolder($DialogText,$RootDir,$FileNeedExists) While True Local $DIR = FileSelectFolder($DialogText,$RootDir) If Not @error Then If FileExists($DIR & "\" & $FileNeedExists) Then IniWrite("C:\Setup.ini", "Location", "dir", $DIR) ;is that right or i need to put Then at the end of it? ExitLoop Else MsgBox(0x10,"Error","File " & $FileNeedExists & " doesn't exist is this folder." & @CRLF & "Please try again.") EndIf Else ExitLoop EndIf WEnd Return $DIR EndFunc Link to comment Share on other sites More sharing options...
Andreik Posted August 26, 2009 Share Posted August 26, 2009 (edited) It's ok the line where you place IniWrite() and you should use _FileSelectFolder function in this way: If IniRead("C:\Setup.ini","Location","dir","EMPTY") = "EMPTY" Then _FileSelectFolder("Select","","calc.exe") That mean that run _FileSelectFolder function if C:\Setup.ini,section Location, key dir don't exist or an error occured IniRead function. Edited August 26, 2009 by Andreik When the words fail... music speaks. 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