FileDialog reports file in use

I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.

How can I make FileDialog just select the file and return the path and file
name without trying to access the file?

The command I am currently using:
        open_dlg = wx.FileDialog(self, message=message, defaultDir=open_dir,
defaultFile=default_file,
                        wildcard=wcd, style=wx.OPEN|wx.CHANGE_DIR)

Thanks

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/FileDialog-reports-file-in-use-tp5718073.html
Sent from the wxPython-users mailing list archive at Nabble.com.

swiper wrote:

I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.

How can I make FileDialog just select the file and return the path and file
name without trying to access the file?

I'm not sure there is a solution to this problem. I believe the
underlying Windows API (GetOpenFileName) tries to verify that you have
permission to open the file, and that operation won't work if the file
is opened exclusively by someone else

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

If the files is opened exclusively and permanently by the Database then there is no point in allowing the user to select it as they will not be able to use it.

···

On 16/07/13 18:30, Tim Roberts wrote:

swiper wrote:

I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.

How can I make FileDialog just select the file and return the path and file
name without trying to access the file?

I'm not sure there is a solution to this problem. I believe the
underlying Windows API (GetOpenFileName) tries to verify that you have
permission to open the file, and that operation won't work if the file
is opened exclusively by someone else

BTW, on Windows the other program can be the preview window in Explorer - it doesn't seem to release file handles until I don't know when - probably to speed up the next access which might never happen.

Werner

···

On 16/07/2013 08:38, swiper wrote:

I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.

actually write any code that would clobber the file once it's selected!)?
Then you could use this style:
wx.FD_OVERWRITE_PROMPT For save dialog only: prompt for a confirmation
if a file will be overwritten.

···

On Mon, Jul 15, 2013 at 11:38 PM, swiper <drcsturm@gmail.com> wrote:

I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open
button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.

How can I make FileDialog just select the file and return the path and file
name without trying to access the file?

The command I am currently using:
        open_dlg = wx.FileDialog(self, message=message,
defaultDir=open_dir,
defaultFile=default_file,
                        wildcard=wcd, style=wx.OPEN|wx.CHANGE_DIR)

Thanks

What if you use a Save dialog instead (being careful, of course, not to

Thanks for the feedback.
I am interested in having the user select a file that is in use by a different program so I can store the file location for later use when the file is not open else where.

So I need the user to specify the file location regardless of the file being open.

I used Marc’s suggestion of changing from wx.OPEN to wx.SAVE. That worked for me. I didn’t use the wx.FD_OVERWRITE_PROMPT because the file already exists and when selected the warning box pops up.

I am not immediately writing to the file so that is not a concern for me.

I was hoping to keep the open option because open is more intuitive but save works for now.

Thanks for all your help. It was very useful.

···

On Tue, Jul 16, 2013 at 4:13 PM, Marc Tompkins [via wxPython-users] <[hidden email]> wrote:

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

For more options, visit https://groups.google.com/groups/opt_out.


If you reply to this email, your message will be added to the discussion below:

http://wxpython-users.1045709.n5.nabble.com/FileDialog-reports-file-in-use-tp5718073p5718079.html

To unsubscribe from FileDialog reports file in use, click here.

  [NAML](http://wxpython-users.1045709.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)

On Mon, Jul 15, 2013 at 11:38 PM, swiper <[hidden email]> wrote:

I would like to use the FileDialog to allow the user to select the location

of a database file which will be used in the program.

The database is used at the same time by another program and this other

program is always on.

When FileDialog is ran and the database file is selected and the Open button

pressed a message appears:

“File in use.” and I am not able to select the file. The file is in use by

another program but I just want to get the path and filename.

How can I make FileDialog just select the file and return the path and file

name without trying to access the file?

The command I am currently using:

    open_dlg = wx.FileDialog(self, message=message, defaultDir=open_dir,

defaultFile=default_file,

                    wildcard=wcd, style=wx.OPEN|wx.CHANGE_DIR)

Thanks

What if you use a Save dialog instead (being careful, of course, not to actually write any code that would clobber the file once it’s selected!)?

Then you could use this style:

wx.FD_OVERWRITE_PROMPT For save dialog only: prompt for a confirmation if a file will be overwritten.

Marc Tompkins wrote:

What if you use a Save dialog instead (being careful, of course, not
to actually write any code that would clobber the file once it's
selected!)?
Then you could use this style:
wx.FD_OVERWRITE_PROMPT For save dialog only: prompt for a
confirmation if a file will be overwritten.

That will have the same problem. The File Save Dialog checks to see
that the file is writable by you.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

of course, but hey.)

···

On Tue, Jul 16, 2013 at 2:48 PM, swiper <drcsturm@gmail.com> wrote:

save works for now.

Sometimes that's all we can hope for. Glad it worked out (not perfectly,