123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /* ***************************************
- * BrowseForFolder.cs
- * ---------------------------------------
- * - Requirements -
- *
- * You have to include the
- * System.Design.dll in your References
- * (Project/Add Reference from menu)
- * ---------------------------------------
- * - Example -
- *
- string myPath;
- BrowseForFolderClass myFolderBrowser = new BrowseForFolderClass();
- myPath = myFolderBrowser.BrowseForFolder("Please, select a folder");
- if (myPath.Length > 0)
- txtPath.Text = myPath;
- * ****************************************/
- using System;
- using System.Windows.Forms;
- using System.Windows.Forms.Design;
- namespace Utility.BrowseForFolder
- {
- public class BrowseForFolderClass : FolderNameEditor
- {
- FolderNameEditor.FolderBrowser myFolderBrowser;
- public string BrowseForFolder(string title)
- {
- string myPath;
-
- myFolderBrowser = new FolderNameEditor.FolderBrowser();
-
- // Description
- myFolderBrowser.Description = title;
- // ShowDialog
- myFolderBrowser.ShowDialog();
- // DirectoryPath
- myPath = myFolderBrowser.DirectoryPath;
- // Shall I add the "\" character at the end of the path ?
- if (myPath.Length > 0)
- {
- if (myPath.Substring((myPath.Length - 1),1) != "\\")
- myPath += "\\";
- }
- // Return correct path
- return myPath;
- }
-
- ~BrowseForFolderClass()
- {
- myFolderBrowser.Dispose(); // Dispose
- }
- }
- }
|