pick up a FOLDER with a nice explorer

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

    pick up a FOLDER with a nice explorer


    I want to use the ordinary OpenFileDialog to choose a folder instead
    of a file. Is it possible? And how?

    [I do not want to use the standard FolderBrowserDi alog, because too
    ugly and poor for my taste]


    -P

  • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

    #2
    RE: pick up a FOLDER with a nice explorer

    No, because the OpenFileDialog was not designed to "open" a folder. Now,
    having said that, if the FolderBrowserDi alog doesn't suit your high-fashion
    couture, you are free to derive from it and "soup it up"... ;-)
    -- Peter
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    bogMetaFinder: http://www.blogmetafinder.com



    "pamela fluente" wrote:
    >
    I want to use the ordinary OpenFileDialog to choose a folder instead
    of a file. Is it possible? And how?
    >
    [I do not want to use the standard FolderBrowserDi alog, because too
    ugly and poor for my taste]
    >
    >
    -P
    >
    >

    Comment

    • rowe_newsgroups

      #3
      Re: pick up a FOLDER with a nice explorer

      On Jul 20, 1:08 pm, Peter Bromberg [C# MVP]
      <pbromb...@yaho o.yohohhoandabo ttleofrum.comwr ote:
      No, because the OpenFileDialog was not designed to "open" a folder. Now,
      having said that, if the FolderBrowserDi alog doesn't suit your high-fashion
      couture, you are free to derive from it and "soup it up"... ;-)
      -- Peter
      Recursion: see Recursion
      site: http://www.eggheadcafe.com
      unBlog: http://petesbloggerama.blogspot.com
      bogMetaFinder: http://www.blogmetafinder.com
      >
      "pamela fluente" wrote:
      >
      I want to use the ordinary OpenFileDialog to choose a folder instead
      of a file. Is it possible? And how?
      >
      [I do not want to use the standard FolderBrowserDi alog, because too
      ugly and poor for my taste]
      >
      -P

      Recursion: see Recursion
      That just made my day :-)

      Thanks,

      Seth Rowe

      Comment

      • rowe_newsgroups

        #4
        Re: pick up a FOLDER with a nice explorer

        On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yah oo.comwrote:
        On Jul 20, 1:08 pm, Peter Bromberg [C# MVP]
        >
        >
        >
        <pbromb...@yaho o.yohohhoandabo ttleofrum.comwr ote:
        No, because the OpenFileDialog was not designed to "open" a folder. Now,
        having said that, if the FolderBrowserDi alog doesn't suit your high-fashion
        couture, you are free to derive from it and "soup it up"... ;-)
        -- Peter
        Recursion: see Recursion
        site: http://www.eggheadcafe.com
        unBlog: http://petesbloggerama.blogspot.com
        bogMetaFinder: http://www.blogmetafinder.com
        >
        "pamela fluente" wrote:
        >
        I want to use the ordinary OpenFileDialog to choose a folder instead
        of a file. Is it possible? And how?
        >
        [I do not want to use the standard FolderBrowserDi alog, because too
        ugly and poor for my taste]
        >
        -P
        Recursion: see Recursion
        >
        That just made my day :-)
        >
        Thanks,
        >
        Seth Rowe
        Darn google trimmed my quote again - the "Recursion: see Recursion"
        quote is what I was referring to with "made my day"

        Thanks,

        Seth Rowe

        Comment

        • pamela fluente

          #5
          Re: pick up a FOLDER with a nice explorer

          On 20 Lug, 19:33, rowe_newsgroups <rowe_em...@yah oo.comwrote:
          On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yah oo.comwrote:
          Darn google trimmed my quote again - the "Recursion: see Recursion"
          quote is what I was referring to with "made my day"

          That would be a nice quote, except for the fact that is an infinite
          loop, not a recursion.

          (That's always my "high-fashion couture")

          -P




          Comment

          • \(O\)enone

            #6
            Re: pick up a FOLDER with a nice explorer

            Peter Bromberg [C# MVP] wrote:
            No, because the OpenFileDialog was not designed to "open" a folder.
            There's something that looks suspiciously like it that *is* designed to
            select a folder though. In VS2005, open the Tools/Options window, select the
            root "Projects and Solutions" tree node and then click the "..." button next
            to one of the location boxes at the top of the dialog. That definitely looks
            like the OpenFileDialog to me, and it's selecting a folder rather than a
            file.

            Can the OpenFileDialog do that? I must confess I haven't tried it.

            (I too find the FolderBrowserDi alog quite irritating, not least of which
            because you can't type in it, making all selections tedious click-fests and
            also making it impossible to select folders via UNC locations).

            --

            (O)enone


            Comment

            • pamela fluente

              #7
              Re: pick up a FOLDER with a nice explorer

              On 20 Lug, 23:43, "\(O\)enone " <oen...@nowhere .comwrote:
              Peter Bromberg [C# MVP] wrote:
              >
              No, because the OpenFileDialog was not designed to "open" a folder.
              >
              There's something that looks suspiciously like it that *is* designed to
              select a folder though. In VS2005, open the Tools/Options window, select the
              root "Projects and Solutions" tree node and then click the "..." button next
              to one of the location boxes at the top of the dialog. That definitely looks
              like the OpenFileDialog to me, and it's selecting a folder rather than a
              file.
              >
              Can the OpenFileDialog do that? I must confess I haven't tried it.
              >
              (I too find the FolderBrowserDi alog quite irritating, not least of which
              because you can't type in it, making all selections tedious click-fests and
              also making it impossible to select folders via UNC locations).
              >
              --
              >
              (O)enone
              Let's discuss this idea (perhaps a stupid one).

              When I explore my folders using the OpenFileDialog there must be some
              place where the current folder is recorded.

              Can I get that information, from environment or whatever, and return
              it when the dialog is closed by the user with OK ?

              If one could do that, I think we would have a nice folder browser.

              (And actually I do not see why the OpenFileDialog , which is nice,
              could not also serve, possibly with appropriate properties, to select
              folders. It seems quite stupid to have an additional dialog, an even
              an ugly one.)

              -P



              Comment

              • pamela fluente

                #8
                Re: pick up a FOLDER with a nice explorer

                For instance see this:

                Public Class Form1
                Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
                As System.EventArg s) _
                Handles Button1.Click

                Dim MyPath As String = SelectAFolder()

                If MyPath IsNot Nothing Then
                MsgBox("Path selected is " & MyPath)
                End If

                End Sub


                Function SelectAFolder() As String

                Dim SelectedPath As String = Nothing

                Using Ofd As New OpenFileDialog
                With Ofd
                .RestoreDirecto ry = False 'crucial

                If .ShowDialog() Then
                SelectedPath = Environment.Cur rentDirectory
                End If
                End With
                End Using

                Return SelectedPath

                End Function

                End Class


                Now what is missing is just a slight change of behavior of the button
                (ok instead of open folder). Then we would have a nice folder browser.

                Can we do that ?


                -P

                Comment

                • Peter Duniho

                  #9
                  Re: pick up a FOLDER with a nice explorer

                  On Fri, 20 Jul 2007 14:43:50 -0700, (O)enone <oenone@nowhere .comwrote:
                  Peter Bromberg [C# MVP] wrote:
                  >No, because the OpenFileDialog was not designed to "open" a folder.
                  >
                  There's something that looks suspiciously like it that *is* designed to
                  select a folder though. In VS2005, open the Tools/Options window, select
                  the
                  root "Projects and Solutions" tree node and then click the "..." button
                  next
                  to one of the location boxes at the top of the dialog. That definitely
                  looks
                  like the OpenFileDialog to me, and it's selecting a folder rather than a
                  file.
                  >
                  Can the OpenFileDialog do that? I must confess I haven't tried it.
                  It probably is based on the OpenFileDialog, though I suppose you'd have to
                  watch it in a debugger to be sure (or ask the guy who wrote it). You
                  could do something similar by creating a new dialog derived from the
                  OpenFileDialog and/or the native Win32 common file open dialog, and
                  overriding the base behavior so that the "Open" button returns with path
                  and no filename.

                  But it's a big UI mistake to do that, IMHO. I don't see what the fuss
                  about the folder browser dialog is. I agree it'd be nice to have better
                  typing control over the browser, but overloading the file browser to
                  return folders results in some pretty user-unfriendly behavior.

                  In the example you describe, contrary to what the user normally expects,
                  selecting a folder and clicking the "Open" button dismisses the dialog
                  rather than descending into the directory tree. The fact that the dialog
                  looks so much like the usual common dialog makes the behavior that much
                  worse; it should at least be visibly and significantly different from the
                  standard dialog, to ensure the user understands they are dealing with
                  something different.

                  The folder browser dialog makes it very clear that you're doing something
                  different from choosing a file. The UI is so different, there's no chance
                  the user will get confused about what button does what.

                  VS should have used the folder browser in that situation. They've
                  violated the basic rule of UI: the rule of least surprise.

                  Pete

                  Comment

                  • Peter Duniho

                    #10
                    Re: pick up a FOLDER with a nice explorer

                    On Fri, 20 Jul 2007 15:28:09 -0700, pamela fluente
                    <pamelafluente@ libero.itwrote:
                    [...]
                    Can we do that ?
                    Do what? Post VB code in a C# newsgroup?

                    No. You're not allowed to do that.




                    :)

                    Comment

                    • pamela fluente

                      #11
                      Re: pick up a FOLDER with a nice explorer

                      On 21 Lug, 00:40, "Peter Duniho" <NpOeStPe...@nn owslpianmk.comw rote:
                      On Fri, 20 Jul 2007 15:28:09 -0700, pamela fluente
                      >
                      <pamelaflue...@ libero.itwrote:
                      [...]
                      Can we do that ?
                      >
                      Do what? Post VB code in a C# newsgroup?
                      >
                      No. You're not allowed to do that.
                      >
                      :)

                      Should we still really make a difference ?

                      for the C# readers only: ----------begin---------


                      using System;
                      using System.Collecti ons.Generic;
                      using System.Componen tModel;
                      using System.Data;
                      using System.Drawing;
                      using System.Text;
                      using System.Windows. Forms;

                      namespace FolderBrowserTe st
                      {
                      public partial class Form1 : Form
                      {
                      public Form1()
                      {
                      InitializeCompo nent();
                      }

                      private void button1_Click(o bject sender, EventArgs e)
                      {
                      string MyPath = SelectAFolder() ;
                      if (MyPath != null)
                      {
                      this.Text = "Path selected is " + MyPath;
                      }
                      }


                      public string SelectAFolder()
                      {
                      string SelectedPath = null;
                      using (OpenFileDialog Ofd = new OpenFileDialog( ))
                      {
                      {
                      Ofd.RestoreDire ctory = false;
                      //crucial

                      if (Ofd.ShowDialog () == DialogResult.OK )
                      {
                      SelectedPath = Environment.Cur rentDirectory;
                      }
                      }
                      }

                      return SelectedPath;
                      }
                      }
                      }


                      for the C# readers only: ----------end---------

                      I am still of the opinion that the 2 dialogs should be unified.

                      Is anybody able to simply change sligtly the behavior of the file
                      browser ?

                      -P

                      Comment

                      • pamela fluente

                        #12
                        Re: pick up a FOLDER with a nice explorer

                        On 21 Lug, 00:38, "Peter Duniho" <NpOeStPe...@nn owslpianmk.comw rote:
                        On Fri, 20 Jul 2007 14:43:50 -0700, (O)enone <oen...@nowhere .comwrote:
                        Peter Bromberg [C# MVP] wrote:
                        >
                        In the example you describe, contrary to what the user normally expects,
                        selecting a folder and clicking the "Open" button dismisses the dialog
                        rather than descending into the directory tree.
                        If this were the difficulty we would be doing a different form for
                        anything.
                        Programming is about being general, unifying and reusing.

                        It's sufficient to have (in browse folder mode) 2 buttons: on to open
                        and one
                        to select.

                        Still do not see the point to create an additional dialog, especially
                        if it is
                        quite ugly and irritating to use.

                        -P

                        Comment

                        • Peter Duniho

                          #13
                          Re: pick up a FOLDER with a nice explorer

                          On Sat, 21 Jul 2007 00:59:20 -0700, pamela fluente
                          <pamelafluente@ libero.itwrote:
                          >Do what? Post VB code in a C# newsgroup?
                          >>
                          >No. You're not allowed to do that.
                          >>
                          >:)
                          >
                          >
                          Should we still really make a difference ?
                          It was a joke. Please note the "emoticon" (aka "smiley") that I posted,
                          and which you quoted.
                          [...]
                          Is anybody able to simply change sligtly the behavior of the file
                          browser ?
                          You may be able to override the behavior using the standard C#
                          mechanisms. If not, then for sure you can override the behavior by using
                          the WndProc override and handling the various Windows messages. There's
                          all sorts of things you can do with the common dialogs via this mechanism,
                          if you really want to.

                          But read my other post. The point is that people shouldn't be going
                          around changing the fundamental behaviors of a shared UI element. It's
                          very bad for the user. If your sense of aesthetics is offended by not
                          having the same visual thing do different things in different contexts,
                          then it's your sense of aesthetics that needs fixing, not the UI element.

                          Pete

                          Comment

                          • Ben Voigt [C++ MVP]

                            #14
                            Re: pick up a FOLDER with a nice explorer


                            "pamela fluente" <pamelafluente@ libero.itwrote in message
                            news:1184953348 .273520.167220@ m3g2000hsh.goog legroups.com...
                            On 20 Lug, 19:33, rowe_newsgroups <rowe_em...@yah oo.comwrote:
                            >On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yah oo.comwrote:
                            >
                            >Darn google trimmed my quote again - the "Recursion: see Recursion"
                            >quote is what I was referring to with "made my day"
                            >
                            >
                            That would be a nice quote, except for the fact that is an infinite
                            loop, not a recursion.
                            It is indeed a recursive definition. And as you say, it is infinitely
                            recursive. But not all self-referential definitions are infinitely
                            recursive.


                            Comment

                            • pamela fluente

                              #15
                              Re: pick up a FOLDER with a nice explorer

                              On 23 Lug, 20:16, "Ben Voigt [C++ MVP]" <r...@nospam.no spamwrote:
                              "pamela fluente" <pamelaflue...@ libero.itwrote in message
                              >
                              news:1184953348 .273520.167220@ m3g2000hsh.goog legroups.com...
                              >
                              On 20 Lug, 19:33, rowe_newsgroups <rowe_em...@yah oo.comwrote:
                              On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yah oo.comwrote:
                              >
                              Darn google trimmed my quote again - the "Recursion: see Recursion"
                              quote is what I was referring to with "made my day"
                              >
                              That would be a nice quote, except for the fact that is an infinite
                              loop, not a recursion.
                              >
                              It is indeed a recursive definition. And as you say, it is infinitely
                              recursive. But not all self-referential definitions are infinitely
                              recursive.
                              You may want to read some basics:





                              -P

                              Comment

                              Working...