PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 Open a CommonDialog(VB6..esque) to let user choose a directory?-VBForums
Results 1 to 4 of 4

Thread: Open a CommonDialog(VB6..esque) to let user choose a directory?

  1. #1

    Thread Starter
    Join Date
    Mar 2012

    Open a CommonDialog(VB6..esque) to let user choose a directory?

    Hi folks, I'm wrestling with some old vb6 codes and upgrade/convert them to.NET. and as some of you are aware of, in .NET the CommonDialog control is divided into OpenFileDialog, SaveFileDialog, ColorDialog, FontDialog, and PrintDialog components.
    This causes a problem for me: my old vb6 code used
    ComDialog.filename = strProductSN & ".LOG"
       strfilename0 = ComDialog.filename
    strDirPath = FileSystem.CurDir$
    which essentially opens up a dialog box with strProductSN & ".LOG"
    in the file name field, then allows the user to navigate to a desired location.
    Then the filename information is saved to strfilename0, and the directory information is saved to strDirPath.
    These info are later used when creating log files.

    And now in .NET apparently i can't do this with either OpenFileDialog or SaveFileDialog. as they both ask me to actually perform an Open or Save operation right away.

    I guess I'm just looking for a simple alternative that can prompts the user a dialog box of some sort that lets the user to specify a filename and a path, which information is then stored in the strings.

    Sorry for the lengthy post..I guess there's probly very simple answer to my problem.. but any suggestions appreciated. THX

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009

    Re: Open a CommonDialog(VB6..esque) to let user choose a directory?

    FolderBrowserDialog lets you browse for a directory. For some advanced Vista/Windows 7 dialogs (such as a folder browser dialog that looks like the Open/SaveFileDialog) you can check out this link: Ookii.Dialogs.

    Mis-read the post, however, still check out the link.
    Last edited by ForumAccount; Jul 10th, 2012 at 11:34 AM.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Open a CommonDialog(VB6..esque) to let user choose a directory?

    You appear to be under some misconceptions about the OpenFileDialog and SaveFileDialog. All they really do is let the user choose a file path, where that file is intended to be either a source or destination. They don;t actually open or save anything. You get the selected file path from the FileName property and then do what you like with it.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012

    Re: Open a CommonDialog(VB6..esque) to let user choose a directory?

    Nope. Operates exactly the same ...
    VB Code:
    1. SaveFileDialog1.FileName = "example.log"
    2.         SaveFileDialog1.ShowDialog()
    3.         Label1.Text = SaveFileDialog1.FileName

    Opens the dialog with the filename inserted. User can choose any directory for it to be saved in. Dialog returns full filepath as String with which you can do whatever you wish. Same applies to OpenDialog.

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