Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Posted

_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

Posted

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)

Posted

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
Posted (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 by Andreik

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
×
×
  • Create New...