OpenFileDialog

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ithaqua

    #1

    OpenFileDialog

    I am having problems giving my dialog box the initial directory at runtime.
    I can get it working if I code it at design time, does any one know why this
    code wont allow me to get the initial directory from a Class at runtim.

    with openfiledialog1

    .InitialdDirect ory = MyClass.GetDire ctory

    .ShowDialog()

    end with
    --
    Cheers
    Ithaqua
  • Herfried K. Wagner [MVP]

    #2
    Re: OpenFileDialog

    "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=blue]
    >I am having problems giving my dialog box the initial directory at runtime.
    > I can get it working if I code it at design time, does any one know why
    > this
    > code wont allow me to get the initial directory from a Class at runtim.[/color]

    Error message? What's the exact problem?

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Ithaqua

      #3
      Re: OpenFileDialog

      When I use the following code to get a folder location from my Class it
      allways opens the dialog box at My Documents.

      MyClass
      {
      Folder_location = "C:\"
      }

      with openfiledialog1

      .InitialdDirect ory = MyClass.GetDire ctory

      .ShowDialog()

      end with

      How ever if I hard code it like this it opens in the specified directory

      with openfiledialog1

      .InitialdDirect ory = "C:\"

      .ShowDialog()

      end with


      --
      Cheers
      Ithaqua


      "Herfried K. Wagner [MVP]" wrote:
      [color=blue]
      > "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=green]
      > >I am having problems giving my dialog box the initial directory at runtime.
      > > I can get it working if I code it at design time, does any one know why
      > > this
      > > code wont allow me to get the initial directory from a Class at runtim.[/color]
      >
      > Error message? What's the exact problem?
      >
      > --
      > M S Herfried K. Wagner
      > M V P <URL:http://dotnet.mvps.org/>
      > V B <URL:http://classicvb.org/petition/>
      >
      >[/color]

      Comment

      • Ithaqua

        #4
        Re: OpenFileDialog

        When I use the following code to get a folder location from my Class it
        allways opens the dialog box at My Documents.

        MyClass
        {
        Folder_location = "C:\"
        }

        with openfiledialog1

        .InitialdDirect ory = MyClass.GetDire ctory

        .ShowDialog()

        end with

        How ever if I hard code it like this it opens in the specified directory

        with openfiledialog1

        .InitialdDirect ory = "C:\"

        .ShowDialog()

        end with


        --
        Cheers
        Ithaqua


        "Herfried K. Wagner [MVP]" wrote:
        [color=blue]
        > "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=green]
        > >I am having problems giving my dialog box the initial directory at runtime.
        > > I can get it working if I code it at design time, does any one know why
        > > this
        > > code wont allow me to get the initial directory from a Class at runtim.[/color]
        >
        > Error message? What's the exact problem?
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://classicvb.org/petition/>
        >
        >[/color]

        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: OpenFileDialog

          "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=blue]
          > When I use the following code to get a folder location from my Class it
          > allways opens the dialog box at My Documents.
          >
          > MyClass
          > {
          > Folder_location = "C:\"
          > }
          >
          > with openfiledialog1
          >
          > .InitialdDirect ory = MyClass.GetDire ctory[/color]

          Where is 'GetDirectory' defined?

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • Ithaqua

            #6
            Re: OpenFileDialog

            It is defined in MyClass.

            --
            Cheers
            Ithaqua


            "Herfried K. Wagner [MVP]" wrote:
            [color=blue]
            > "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=green]
            > > When I use the following code to get a folder location from my Class it
            > > allways opens the dialog box at My Documents.
            > >
            > > MyClass
            > > {
            > > Folder_location = "C:\"
            > > }
            > >
            > > with openfiledialog1
            > >
            > > .InitialdDirect ory = MyClass.GetDire ctory[/color]
            >
            > Where is 'GetDirectory' defined?
            >
            > --
            > M S Herfried K. Wagner
            > M V P <URL:http://dotnet.mvps.org/>
            > V B <URL:http://classicvb.org/petition/>
            >[/color]

            Comment

            • Cor Ligthert [MVP]

              #7
              Re: OpenFileDialog

              Ithaqua,

              Forgive me that I had so smile, that it is in MyClass (although not litary I
              hope because that is a keyword), does Herfried for sure know.

              I think that he did more wanted to know where the information came from that
              is in MyClass. (And if you checked that the information was really correct.)

              Cor

              "Ithaqua" <Ithaqua@discus sions.microsoft .com> schreef in bericht
              news:5DEDCA1F-7588-4516-88F3-20F4275D4C96@mi crosoft.com...[color=blue]
              > It is defined in MyClass.
              >
              > --
              > Cheers
              > Ithaqua
              >
              >
              > "Herfried K. Wagner [MVP]" wrote:
              >[color=green]
              >> "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=darkred]
              >> > When I use the following code to get a folder location from my Class it
              >> > allways opens the dialog box at My Documents.
              >> >
              >> > MyClass
              >> > {
              >> > Folder_location = "C:\"
              >> > }
              >> >
              >> > with openfiledialog1
              >> >
              >> > .InitialdDirect ory = MyClass.GetDire ctory[/color]
              >>
              >> Where is 'GetDirectory' defined?
              >>
              >> --
              >> M S Herfried K. Wagner
              >> M V P <URL:http://dotnet.mvps.org/>
              >> V B <URL:http://classicvb.org/petition/>
              >>[/color][/color]


              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: OpenFileDialog

                "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=blue]
                > It is defined in MyClass.[/color]

                First, 'MyClass' is a reserved keyword in VB.NET, second there might be a
                bug in the implementation of the method.

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://classicvb.org/petition/>

                Comment

                • beaker

                  #9
                  Re: OpenFileDialog

                  Ithaqua wrote:[color=blue]
                  > When I use the following code to get a folder location from my Class it
                  > allways opens the dialog box at My Documents.
                  >
                  > MyClass
                  > {
                  > Folder_location = "C:\"
                  > }
                  >
                  > with openfiledialog1
                  >
                  > .InitialdDirect ory = MyClass.GetDire ctory
                  >
                  > .ShowDialog()
                  >
                  > end with
                  >
                  > How ever if I hard code it like this it opens in the specified directory
                  >
                  > with openfiledialog1
                  >
                  > .InitialdDirect ory = "C:\"
                  >
                  > .ShowDialog()
                  >
                  > end with
                  >
                  >[/color]

                  Can you post the code for your GetDirectory method here.... I'm guessing
                  the problem may be there.

                  Comment

                  • Ithaqua

                    #10
                    Re: OpenFileDialog

                    Sorry MyClass is not actually the class name, it was just one I made up.
                    --
                    Cheers
                    Ithaqua


                    "Herfried K. Wagner [MVP]" wrote:
                    [color=blue]
                    > "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=green]
                    > > It is defined in MyClass.[/color]
                    >
                    > First, 'MyClass' is a reserved keyword in VB.NET, second there might be a
                    > bug in the implementation of the method.
                    >
                    > --
                    > M S Herfried K. Wagner
                    > M V P <URL:http://dotnet.mvps.org/>
                    > V B <URL:http://classicvb.org/petition/>
                    >
                    >[/color]

                    Comment

                    • Ithaqua

                      #11
                      Re: OpenFileDialog

                      I have checked and this returns the directory location like it should.


                      ReadOnly Property getDirectory()
                      Get

                      ' Get the value of the private class variable in one instance
                      Return _directoryLocat ion

                      End Get
                      End Property
                      --
                      Cheers
                      Ithaqua


                      "beaker" wrote:
                      [color=blue]
                      > Ithaqua wrote:[color=green]
                      > > When I use the following code to get a folder location from my Class it
                      > > allways opens the dialog box at My Documents.
                      > >
                      > > MyClass
                      > > {
                      > > Folder_location = "C:\"
                      > > }
                      > >
                      > > with openfiledialog1
                      > >
                      > > .InitialdDirect ory = MyClass.GetDire ctory
                      > >
                      > > .ShowDialog()
                      > >
                      > > end with
                      > >
                      > > How ever if I hard code it like this it opens in the specified directory
                      > >
                      > > with openfiledialog1
                      > >
                      > > .InitialdDirect ory = "C:\"
                      > >
                      > > .ShowDialog()
                      > >
                      > > end with
                      > >
                      > >[/color]
                      >
                      > Can you post the code for your GetDirectory method here.... I'm guessing
                      > the problem may be there.
                      >[/color]

                      Comment

                      • Herfried K. Wagner [MVP]

                        #12
                        Re: OpenFileDialog

                        "Ithaqua" <Ithaqua@discus sions.microsoft .com> schrieb:[color=blue]
                        >I have checked and this returns the directory location like it should.
                        >
                        >
                        > ReadOnly Property getDirectory()
                        > Get
                        >
                        > ' Get the value of the private class variable in one instance
                        > Return _directoryLocat ion
                        >
                        > End Get
                        > End Property[/color]

                        Although this won't solve the problem

                        \\\
                        Public ReadOnly Property Directory() As String
                        Get
                        Reurn ...
                        End Get
                        End Property
                        ///

                        should be preferred.

                        --
                        M S Herfried K. Wagner
                        M V P <URL:http://dotnet.mvps.org/>
                        V B <URL:http://classicvb.org/petition/>

                        Comment

                        • Harry Strybos

                          #13
                          Re: OpenFileDialog

                          "Ithaqua" <Ithaqua@discus sions.microsoft .com> wrote in message
                          news:E8DF66C3-5E61-474D-9E56-71D20EFDCAE7@mi crosoft.com...[color=blue]
                          >I am having problems giving my dialog box the initial directory at runtime.
                          > I can get it working if I code it at design time, does any one know why
                          > this
                          > code wont allow me to get the initial directory from a Class at runtim.
                          >
                          > with openfiledialog1
                          >
                          > .InitialdDirect ory = MyClass.GetDire ctory
                          >
                          > .ShowDialog()
                          >
                          > end with
                          > --
                          > Cheers
                          > Ithaqua[/color]

                          Shouldn't that be: .InitialDirecto ry without the extra "d"


                          Comment

                          • Ithaqua

                            #14
                            Re: OpenFileDialog

                            Sorry that is a typeo in my post to this group

                            --
                            Cheers
                            Ithaqua


                            "Harry Strybos" wrote:
                            [color=blue]
                            > "Ithaqua" <Ithaqua@discus sions.microsoft .com> wrote in message
                            > news:E8DF66C3-5E61-474D-9E56-71D20EFDCAE7@mi crosoft.com...[color=green]
                            > >I am having problems giving my dialog box the initial directory at runtime.
                            > > I can get it working if I code it at design time, does any one know why
                            > > this
                            > > code wont allow me to get the initial directory from a Class at runtim.
                            > >
                            > > with openfiledialog1
                            > >
                            > > .InitialdDirect ory = MyClass.GetDire ctory
                            > >
                            > > .ShowDialog()
                            > >
                            > > end with
                            > > --
                            > > Cheers
                            > > Ithaqua[/color]
                            >
                            > Shouldn't that be: .InitialDirecto ry without the extra "d"
                            >
                            >
                            >[/color]

                            Comment

                            • iwdu15

                              #15
                              Re: OpenFileDialog

                              you could try

                              application.sta rtuppath

                              that would get the filder of where your app started

                              -iwdu150

                              Comment

                              Working...