Results 1 to 5 of 5

Thread: CFileDialog changes the current directory..argh!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    CFileDialog changes the current directory..argh!

    I present a standard open dialog to the user. Once the user makes a file selection, the file is manipulated.

    Later in the code, having NOTHING to do with the file\path that was retrieved from the dialog, I must create a "error.log" file where the application resides. Little did I know, but the path changed!!!

    Example:

    1) Program executed, current path = C:\Temp
    2) Dialog selection made, current path CHANGED to F:\Directory
    3) Call Open("error.log", mode::Create..etc). File created in F:\Directory\error.log

    What can I do to prevent this? I tried calling the ::GetCurrentDirectory() in the dialog's constructor, but received a ASSERT. Also calling from OnInitDialog() fails.

    Any suggestions?

    Thanks
    Phil

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There's a flag, OFN_DONTCHANGEDIR or something like that, which prevents the common dialog from changing the working directory.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170
    Exactly...thanks!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170
    Well, how can I prevent this:

    A shortcut to the application is placed on the desktop. When the user executes the program from the shortcut, the initial current directory becomes the desktop and thus the error.log file is generated on the desktop.

    Could I prevent this?

    Phil

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Specifiy the working directory in the shortcut property to be something else.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width