Results 1 to 3 of 3

Thread: [2.0] Setting the initial directory of OpenFileDialog to the desktop

  1. #1

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    [2.0] Setting the initial directory of OpenFileDialog to the desktop

    Hi everyone!

    I trying to set the initial directory of the open file dialog to the desktop could anyone help me?

    OpenFileDialog fdlg = new OpenFileDialog();
    fdlg.InitialDirectory = @"c:\";

    How do I set it to the desktop without doing something like this:

    fdlg.InitialDirectory = @"C:\Documents and Settings\Jennifer\Desktop";


    Jennifer.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2.0] Setting the initial directory of OpenFileDialog to the desktop

    The System.Environment.GetFolderPath function will do what you need:

    Code:
    MessageBox.Show(System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop));

  3. #3

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: [2.0] Setting the initial directory of OpenFileDialog to the desktop

    Thanks, it worked - Jennifer

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