How do I change the current path for OpenFileDialog ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGVy?=

    #1

    How do I change the current path for OpenFileDialog ?

    I want to change the current path in the OpenFileDialog in runtime. When the
    user presses OK-button I'm checking the selected path if it's valid for my
    application. If it's not valid I want to set the path to a valid one in the
    FileOk-event and set the e.Cancel = true.
  • CSharper

    #2
    Re: How do I change the current path for OpenFileDialog ?

    On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
    I want to change the current path in the OpenFileDialog in runtime. When the
    user presses OK-button I'm checking the selected path if it's valid for my
    application. If it's not valid I want to set the path to a valid one in the
    FileOk-event and set the e.Cancel = true.
    Can't you use Reset() or InitialDirector y() method?
    Set a valid initial directory and on invalid path perform a reset() on
    the file dialog.

    Comment

    • =?Utf-8?B?UGVy?=

      #3
      Re: How do I change the current path for OpenFileDialog ?



      "CSharper" wrote:
      On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
      I want to change the current path in the OpenFileDialog in runtime. When the
      user presses OK-button I'm checking the selected path if it's valid for my
      application. If it's not valid I want to set the path to a valid one in the
      FileOk-event and set the e.Cancel = true.
      >
      Can't you use Reset() or InitialDirector y() method?
      Set a valid initial directory and on invalid path perform a reset() on
      the file dialog.
      >
      When I do this operation I want the dialog to update and to show the path
      that I'm setting in the method that handles the FileOk-event. If I performs a
      reset the dialog is not updated to the right path it stays on the wrong path.



      Comment

      • CSharper

        #4
        Re: How do I change the current path for OpenFileDialog ?

        On Apr 1, 3:15 am, Per <P...@discussio ns.microsoft.co mwrote:
        "CSharper" wrote:
        On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
        I want to change the current path in the OpenFileDialog in runtime. When the
        user presses OK-button I'm checking the selected path if it's valid for my
        application. If it's not valid I want to set the path to a valid one in the
        FileOk-event and set the e.Cancel = true.
        >
        Can't you use Reset() or InitialDirector y() method?
        Set a valid initial directory and on invalid path perform a reset() on
        the file dialog.
        >
        When I do this operation I want the dialog to update and to show the path
        that I'm setting in the method that handles the FileOk-event. If I performs a
        reset the dialog is not updated to the right path it stays on the wrong path.
        I see your problem. Only way you can do this to make the open dialog
        not to validate the the directory exists or not, this can be done by
        either one of them. First one for directory validation and second one
        is file validation.

        openFileDialog1 .CheckPathExist s = false;
        openFileDialog1 .CheckFileExist s = false;

        by default both are set to true;

        Comment

        • =?Utf-8?B?UGVy?=

          #5
          Re: How do I change the current path for OpenFileDialog ?

          This still did not help. The dialog do not uppdate and show the path that I
          set in my event handler for the OK button.

          "CSharper" wrote:
          On Apr 1, 3:15 am, Per <P...@discussio ns.microsoft.co mwrote:
          "CSharper" wrote:
          On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
          I want to change the current path in the OpenFileDialog in runtime. When the
          user presses OK-button I'm checking the selected path if it's valid for my
          application. If it's not valid I want to set the path to a valid one in the
          FileOk-event and set the e.Cancel = true.
          Can't you use Reset() or InitialDirector y() method?
          Set a valid initial directory and on invalid path perform a reset() on
          the file dialog.
          When I do this operation I want the dialog to update and to show the path
          that I'm setting in the method that handles the FileOk-event. If I performs a
          reset the dialog is not updated to the right path it stays on the wrong path.
          >
          I see your problem. Only way you can do this to make the open dialog
          not to validate the the directory exists or not, this can be done by
          either one of them. First one for directory validation and second one
          is file validation.
          >
          openFileDialog1 .CheckPathExist s = false;
          openFileDialog1 .CheckFileExist s = false;
          >
          by default both are set to true;
          >

          Comment

          • CSharper

            #6
            Re: How do I change the current path for OpenFileDialog ?

            On Apr 2, 7:47 am, Per <P...@discussio ns.microsoft.co mwrote:
            This still did not help. The dialog do not uppdate and show the path that I
            set in my event handler for the OK button."CSharpe r" wrote:
            On Apr 1, 3:15 am, Per <P...@discussio ns.microsoft.co mwrote:
            "CSharper" wrote:
            On Mar 31, 10:39 am, Per <P...@discussio ns.microsoft.co mwrote:
            I want to change the current path in the OpenFileDialog in runtime.. When the
            user presses OK-button I'm checking the selected path if it's valid for my
            application. If it's not valid I want to set the path to a valid one in the
            FileOk-event and set the e.Cancel = true.
            >
            Can't you use Reset() or InitialDirector y() method?
            Set a valid initial directory and on invalid path perform a reset() on
            the file dialog.
            >
            When I do this operation I want the dialog to update and to show the path
            that I'm setting in the method that handles the FileOk-event. If I performs a
            reset the dialog is not updated to the right path it stays on the wrong path.
            >
            I see your problem.  Only way you can do this to make the open dialog
            not to validate the the directory exists or not, this can be done by
            either one of them. First one for directory validation and second one
            is file validation.
            >
            openFileDialog1 .CheckPathExist s = false;
             openFileDialog1 .CheckFileExist s = false;
            >
            by default both are set to true;
            With the change I suggested, when user press ok button, even if the
            file or directory is bad, it should close the fie dialog and you have
            to validate the data yourself and if the data is bad show the file
            dialog again.
            My question, when you press the open button, did the window close or
            did it show the error again?

            If you have the code, please send it and let me have a look.
            Thanks.

            Comment

            Working...