momo33 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perlmonks,

I use Tk to select some files and directories. This works fine in most situations. Unfortunately, it fails with mounted shares (MS Windows). Selecting a file with getOpenFile generally works, but chooseDirectory always fails.
my $dirname=getcwd; my $f = $mw->getOpenFile(-filetypes => $dtype, -initialdir => $dirname); my $d = $mw->chooseDirectory( -initialdir => $dirname); $dirname looks like: //machine123/myshare$/report/data/01/
getOpenFile generally opens the correct directory, chooseDirectory opens mydocuments.
Does anyone know what causes this?

Thank you

Replies are listed 'Best First'.
Re: problem with mounted share (MS Windows)
by rovf (Priest) on Sep 25, 2008 at 08:12 UTC

    Just a wild guess: Are you using UNC pathes for $dirname? If yes, does it work if you use drive letters instead?

    -- 
    Ronald Fischer <ynnor@mm.st>
      Your guess was right: the paths are UNC. Unfortunately drive letters are not an option. Do you have any suggestions?

      Just to be clear, the path looks like: //machine123/myshare$/report/data/01/
        Unfortunately drive letters are not an option.

        Just to make sure that it is really the UNC path which causes griefs: Could you at least try in a test run to use drive letters instead, so that you can confirm the cause?

        I don't know what Tk is doing internally so that your call fails. UNC pathes are OK in *most* cases, but here are two exceptions I know, which don't work with UNC pathes: If you use the Cygwin version of Perl, or if you set *on the command line* the "default drive" to a UNC path (which doesn't seem to apply in your case). But of course there might be other issues I'm not aware of.

        -- 
        Ronald Fischer <ynnor@mm.st>
Re: problem with mounted share (MS Windows)
by BrowserUk (Patriarch) on Sep 25, 2008 at 12:01 UTC
      Probably because Tk doesn't understand UNC pathnames.

      Or, rather, it Tk requires to use \\ instead of // in UNC pathes? Did you try to replace the forward slashes by backslashes?

      -- 
      Ronald Fischer <ynnor@mm.st>
        I tried replacing / by \, but this is very tricky. It caused more problems than it solved.

        The path is provided by getcwd. Can I convert this into something Tk allways handles correctly?
Re: problem with mounted share (MS Windows)
by ikegami (Patriarch) on Sep 26, 2008 at 09:33 UTC

    The dialog is a standard Windows (or library, I can't remember) dialog. I don't think the problem is specific to Tk, and I don't think there's anything you can do about it. It doesn't work using backslashes either.