- Version
- Download 53
- File Size 43.49 KB
- File Count 1
- Create Date May 7, 2016
- Last Updated May 7, 2016
Folder Dialog component in C#
Folder Dialog component in c#
Folder dialog is somewhat similar to open file dialog but the folder dialog in used to browse folders only while open file dialog is used to browse files.
This program will show us to how to get the path or location of the selected folder, the program has also an option that allows you to show and hide the make new folder button in the folder dialog.
Open the project solution (.sln) in visual studio 2010/2012 or open directly the project file (.csproj)
Source code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
label2.Text = folderBrowserDialog1.SelectedPath;
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
folderBrowserDialog1.ShowNewFolderButton = true;
}
else if (checkBox1.Checked == false)
{
folderBrowserDialog1.ShowNewFolderButton = false;
}
}
}
}