Home Ask Login Register

Developers Planet

Your answer is one click away!

Matas Viselga February 2016

How to select a place to create a folder in windows form c#?

I'm doing my computing coursework and I'm creating program where your school files will be synchronized to a selected folder at home(similarly to Dropbox). When you login I need it to ask you the user to select a place and create folder where the files will be synchronized to but I'm not sure how to do it.

I would really appreciate if anyone could provide some examples.


Andy Arndt February 2016

I'll point you to the documentation, that includes examples. You could have easily found this by Googling, though. And if you're doing coursework that involves programming, first lesson is to learn to find things on Google.


René Vogt February 2016

The .NET Framework and Windows.Forms provides you a solution for this. You can simply use a FolderBrowserDialog like this:

using (FolderBrowserDialog dialog = new FolderBrowserDialog())
    dialog.Description = "Select path to synchronize to";
    dialog.RootFolder = Environment.SpecialFolder.Desktop; // or whatever you like
    dialog.SelectedPath = ...; // maybe set this to a previously selected folder
    dialog.ShowNewFolderButton = true; // to enable the user to create a new folder
    if (dialog.ShowDialog() != DialogResult.OK) return; // do what you need if user cancels the dialog

    var selectedPathToSynchronizeTo = dialog.SelectedPath;

This shows the Windows standard folder selection dialog.

Post Status

Asked in February 2016
Viewed 3,354 times
Voted 6
Answered 2 times


Leave an answer

Quote of the day: live life