.NET Development: How to Browse Files, Folders, and Directories

These two videos show you how to work with the file system in Visual Basic .NET, C#, and Visual Studio 2010. This video shows you how to browse drives, folders, and files in a Windows Forms application (though it would work exactly the same in an ASP.NET Web application). This video can help you prepare for the 70-536, 70-515, and 70-511 MCTS or MCPD exams. A C# version of this video is also available.

First, the Visual Basic .NET version:

Now, the C# version:

This entry was posted in Certifications, Development, Video and tagged , , , , , , , by Tony Northrup. Bookmark the permalink.

About Tony Northrup

Tony Northrup, MVP, MCITP, MCPD, MCSE, MCTS, and CISSP, is a Windows consultant and author living in Waterford, Connecticut, in the United States. Tony started programming before Windows 1.0 was released, but has focused on Windows administration and development for the last fifteen years. He has written more than two dozen books covering Windows development, networking, and security. Among other titles, Tony is coauthor of the Windows 7 Resource Kit, the Windows Vista Resource Kit, and Windows Server 2008 Networking and Network Access Protection (NAP). When he's not writing, Tony enjoys photography, travel, and being awesome. Tony lives with his girlfriend, Chelsea, her daughter, Madelyn, and three dogs. You can learn more about Tony by visiting his personal website at http://www.northrup.org and his photography portfolio at http://northrupphotography.com.

3 thoughts on “.NET Development: How to Browse Files, Folders, and Directories

  1. Hi Tony

    I’ve been doing the code code that’s on above Browsing Files and Folders using System.I/O. Im have a problem after i’ve finished creating the 3 listBox and wrote every code and run the application, it compiles fine but when I click the current drivelist it gives me an exception that the object that im trying to select is not set to an instance of the object. It does this with every drive even on removeable drives. I can you please help with this.

    • Hi, Xolani. Sorry you’re having that problem.

      First, check these more detailed articles (one in C#, on in VB):

      Because these are examples meant to focus on a particular topic, I don’t typically add robust exception handling. If it were a real-world application, I certainly would.

      So with that said, I’d have to ask which line of code was causing the exception. You can get exceptions when trying to access drives that aren’t available for one reason or another (such as a removable drive that’s not connected), so my first step would be to add exception handling and choose to ignore drives that aren’t available, or at least display a friendly error to the user.

      You’re also welcome to send me your source code (without any .exe files) to tony@northrup.org and I can try and run it on my side.

      • I didn’t change a bit in the C# code on how to browse file. but the code that give me exception it try & catch on drivelist. The drives are there C:\. I even try to put drive.IsReady but it still gives me “The Object reference not set to an instance of an object”.

        Thank you

Comments are closed.