Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#
Tip/Trick

File and Folder ListView

Rate me:
Please Sign up or sign in to vote.
4.50/5 (7 votes)
4 May 2012CPOL1 min read 55.3K   5.3K   10   8
File and Folder Listview is a simple component that I made as an alternative to OpenFileDialog or CommonOpenFileDialog that does not support selecting both File or Folder.

Image 1 

Introduction

File and Folder Listview is a simple component that I made as an alternative to OpenFileDialog or CommonOpenFileDialog that does not support selecting both File or Folder.

In the standard controls, we use OpenFileDialog to select Files and we use FolderDialog to select Folders. Other common controls released by Microsoft was the CommonOpenFileDialog available in WindowsAPICodePack. The UI looks like the standard OpenFileDialog but it can also select Folders if "IsFolderPicker" property is set to true. But one thing these standard controls cannot do is to the ability to select both File or Folder 

Using the code

In your project, add FileFolderList.cs and drag the control in your form or in any container. FileFolderList is using ListView as it's base class so all the properties, method, and events of the ListView are available.

FileFolderList has 3 custom properties

  • string DefaultPath {get;set;}
  • string SelectedPath {get;}
  • bool isSoloBrowser {get;set;}
    // - when true, it will add "..." so you can go back to the parent folder

and 2 custom methods

  • void Load()
    call this method when your form has loaded 
  • void Browse(string path)  

Adding the control programatically can be done in this way

C#
GCS.Windows.Forms.FileFolderList ffl = new GCS.Windows.Forms.FileFolderList();
ffl.View = View.Details;
ffl.Load();
ffl.Dock = DockStyle.Fill;
this.Controls.Add(ffl); 

Points of Interest

FileFolderList uses BackgroundWorker object to load the associated icons in a separate thread. 

History

this is my initial release 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Capploud
Philippines Philippines
I am an experienced Applications Developer and had worked professionally for over 6 years. I have been writing codes and building different applications for over 13+ years. My work is mostly for Microsoft technologies such as .NET. Yes I am Microsoft technology enthusiast.

My field of expertise in .NET technology are Desktop and Windows Mobile and Windows Phone. I occasionally write ASP.NET too for clients.

I have wide experience of different programming languages and scripts such as: Turbo Pascal, Batch Scripts, C/C++, Visual Basic Classic, Visual Basic .NET, Java, HTML, CSS, ASP Classic, VB Script, ASP.NET, T-SQL, MySQL, PHP, C#, Javascript, jQuery, HTML5, RegEx, XAML, XML, JSON, and XPath

I am also experienced in different platforms such as: Google Data API, Google Map API, Twitter API, Facebook API, Flickr API, Skydrive API, SVN, GitHub, Drupal, and Orchard.

I am interested in Microsoft technologies, User Experience and User Interfaces, Algorithms, Robotics, Astronomy, Architecture, Electrical, Mechanics, and Extra Therestrial Life on other planets.

I am also offering free coding and application development consultations with students having a problem with their Thesis projects.

View my full Curriculum Vitae here
http://ss.jaysonragasa.net/?mycv

Comments and Discussions

 
QuestionI don't see where IsFolderPicker exists Pin
David Fenstemaker19-Aug-16 7:54
David Fenstemaker19-Aug-16 7:54 
Questionset path Pin
Gabee810-Oct-14 1:58
Gabee810-Oct-14 1:58 
GeneralMy vote of 5 Pin
treesprite18-Jul-14 14:33
professionaltreesprite18-Jul-14 14:33 
QuestionFiltering Suggestion? Pin
treesprite18-Jul-14 14:30
professionaltreesprite18-Jul-14 14:30 
GeneralMy vote of 3 Pin
vaivit24-Jun-14 21:16
vaivit24-Jun-14 21:16 
Questionimplement a save function... Pin
treesprite6-Feb-13 12:24
professionaltreesprite6-Feb-13 12:24 
AnswerRe: implement a save function... Pin
Jayson Ragasa6-Feb-13 12:26
Jayson Ragasa6-Feb-13 12:26 
QuestionImages Pin
Mehdi Gholam3-May-12 19:24
Mehdi Gholam3-May-12 19:24 
Please put your images on CodeProject and not elsewhere so it can be viewed easily.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.