Thread: Common Dialog Box in C#?

  1. #1
    Registered User stevespai's Avatar
    Join Date
    Jun 2006
    Posts
    23

    Common Dialog Box in C#?

    Hi, can anyone recommend a good example site or provide an example on how to use a common dialog box in C#? The one on MSDN is confusing to me.

    My program processes .csv files. My goal is to be able to point my program to a directory file which holds the .csv files at the start of the program. Also, I want the user to be able to choose the directory where the program outputs the processed output.

    Thank You.
    Steve

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Code:
    [STAThread]
    static void Main(string[] args)
    {
    	using (FolderBrowserDialog dialog = new FolderBrowserDialog())
    	{
    		//Set the root folder
    		dialog.RootFolder = Environment.SpecialFolder.Desktop;
    
    		//Set the currently selected directory
    		dialog.SelectedPath = Environment.CurrentDirectory;
    
    		//Do you want to allow the user to create folders in this dialog?
    		dialog.ShowNewFolderButton = true;
    
    		//A meaningful description
    		dialog.Description = "This is a description";
    
    		if(dialog.ShowDialog() == DialogResult.OK)
    			MessageBox.Show(dialog.SelectedPath);
    	}
    }
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Registered User stevespai's Avatar
    Join Date
    Jun 2006
    Posts
    23
    Thank you pianorain.

  4. #4
    Registered User stevespai's Avatar
    Join Date
    Jun 2006
    Posts
    23
    Pianorain: How can I specify a specific file to use, rather then just a folder?

  5. #5
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    You'll want to use the OpenFileDialog class.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  6. #6
    Registered User stevespai's Avatar
    Join Date
    Jun 2006
    Posts
    23
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Folder selection menu using Common Dialog Box?
    By Devil Panther in forum Windows Programming
    Replies: 6
    Last Post: 04-29-2007, 01:09 PM
  3. Common Font Dialog Box
    By sethjackson in forum Windows Programming
    Replies: 5
    Last Post: 09-13-2005, 06:58 PM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM