Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

(tye)Re: chdir does not work on win2000

by tye (Sage)
on May 28, 2001 at 21:09 UTC ( #83761=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: chdir does not work on win2000
in thread chdir does not work on win2000

This isn't a problem with chdir, it appears to be a problem specific to directory named "tmp". If I try to chdir to a directory that doesn't exist, then the "Browse" button shows me files in the working directory of the script. If I successfully chdir, then it shows me files in that directory. But on both of those cases, if the directory name is "tmp", then I am instead shown files in the "My Documents" folder. Sounds like just the kind of thing Microsoft would do.

An aside: If you cancel out of the Browse window, you get a two-button dialog box that either throws you back into the Browse window or exits the program. You really should allow the user to cancel the Browse window and return to the original form in case they change their mind about browsing.

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re: chdir does not work on win2000

Replies are listed 'Best First'.
Re: (tye)Re: chdir does not work on win2000
by juo (Curate) on May 31, 2001 at 17:15 UTC

    Dear Tye, Are you using Win2000. With me it doesn't change the directory on Windows2000. When the browser open it shows me the directory last browsed too and not the directory that is returned by cwd(). The directory that is returned by cwd() is the directory were I started the script from. When I use chdir that directory has been changed but the directory in the browser stays untouched. When I browse to another location in the browser and I exit the browser that location is now stored and shown everytime I open the browser even when I reboot. It's that pointer I am not able to change. I believe it must be somewhere a setting in the windows2000 register that is not correct. On Windows NT it is working fine. Did anybody had simular problems ?

    my $_pwd = getcwd(); print "$_pwd\n"; # shows c:/perl/training : directory were I start + from. chdir("c:\\public") or print STDERR "\n\tERROR in chdir: $!\n"; $_pwd = getcwd(); print "$_pwd\n"; # shows c:/perl/public: directory have been chang +ed

      Yes, my experiments were done on Win2K.

      Here is the documentation of the "problem" (from the documentation for the OPENFILENAME structure that is passed to the GetOpenFileName function):

      lpstrInitialDir (a field in that structure)

      Pointer to a string that specifies the initial file directory.

      Windows NT 5.0 and later; Windows 98 and later:

      If lpstrInitalDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.

      If lpstrInitalDir is NULL and the current directory does not contain any files of the specified filter types, the initial directory is the personal files directory of the current user. To specify the current user's personal files directory as the initial directory, set lpstrInitialDir to the path returned by calling theSHGetSpecialFolderLocation function with the CSIDL_PERSONAL flag.

      Earlier versions of Windows and Windows NT:

      If lpstrInitalDir is NULL, the initial directory is the current directory.

      So I was close. The problem isn't with directories named "tmp", it is with directories that don't contain any files of the type you requested to be opened.

      The documentation implies that if you change this value to not be NULL, then things will work as you desire. Checking the source code for Tk (download Tk800_023_tar.gz from CPAN, extract files, find call to GetOpenFileName in Tk800.023\pTk\mTk\win\tkWinDialog.c, etc.) I see that specifying the -initialdir option should take care of that. Of course, you said that you already tried that. ):

      Perhaps you should experiment some more on exactly how you pass the -initialdir in. I know, for example, that file dialogues are one of the few places in Win32 that you can't type forward slash (/) as a directory separator. Perhaps the -initialdir also requires that only back slashes (\) be used?

              - tye (but my friends call me "Tye")

        Tye, You are a cool dude. You were right with you last statement. The -initialdir can only parse through (\) and not (/) The code below did the job right. Thaaaaaaaaaaaaaaaanks

        $file = $w->getOpenFile(-filetypes => \@types, - initialdir => "c:\\public",);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://83761]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2017-10-21 23:26 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (271 votes). Check out past polls.