Sign in to follow this  
Followers 0
Crotaphytus112

FileOpenDialog + All file-types?

4 posts in this topic

Hello there,

I am having some trouble with the FileOpenDialog-function. I want to create a select-file-prompt where the user can select every file-type. I should be able to do it with this:

$filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3)

The prompt and everything works fine, but the problem is that it always seems to return successfull even when the user closes the dialog without chosing a file which obvoiusly causes problems later.

But if I change the filter for file-types to .html or anything other than "all files", it works:

$filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.html)", 3)

So it would seem that using:

"(*.*)"
in the file-type filter always causes FileOpenDialog to return successfull or is it just me? Can I tell the FileOpenDialog to accept alle file-types in another way?

Thanks!

Share this post


Link to post
Share on other sites



Hi and Welcome to the forums!

I tested like this:

$filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3)
ConsoleWrite(@error & @CRLF)

And it works for me, so before we can answer your question you need to post a reproducer (short fully working example) so we know what your exact question is.

Share this post


Link to post
Share on other sites

Hi and Welcome to the forums!

I tested like this:

$filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3)
ConsoleWrite(@error & @CRLF)

And it works for me, so before we can answer your question you need to post a reproducer (short fully working example) so we know what your exact question is.

Thanks for the warm welcome :)

I think I have isolated the error, I am using Opt('MustDeclareVars', 1) in my script, like this:

Opt('MustDeclareVars', 1)

$filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3)

If @error Then
    MsgBox(0,"Error","No file chosen")

Else
    MsgBox(0,"Succes","Succeeded loading HTML-file") 
EndIf

It works if I remove Opt('MustDeclareVars', 1), but can I do that? Can I keep it and somehow declare @ScriptDir instead?

Share this post


Link to post
Share on other sites

It works if I remove Opt('MustDeclareVars', 1), but can I do that? Can I keep it and somehow declare @ScriptDir instead?

Then declare it... ;-)

Global $filepath=...

Share this post


Link to post
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
Sign in to follow this  
Followers 0