Jump to content

FileSelectFolder help


 Share

Recommended Posts

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

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

_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

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

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

When the words fail... music speaks.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...