Create bulk or mass folders using VB.Net functions and Excel spreadsheet
- Details
- Category: Visual Basic.Net
- Published on Tuesday, 25 November 2008 16:11
- Written by Shabdar
- Hits: 21839
Introduction
This sample code tells you how to create a series of folders using folder names stored in an excel spreadsheet.
How to use
- Open any excel spreadsheet which contains folder names. You can get sample spreadsheet from downloaded source.
- Select folder names and copy them from this excel spreadsheet.
- Open downloaded source code with Visual Studio 2005 and run it. Following form should appear.
- Click on Paste from Excel. This should paste values from Excel spreadsheet into DatagridView. If it does not paste, make sure you have copied values from excel spreadsheet.
- Enter path of directory where you want to create folders and make sure it exists.
- Click Create Folders button. This will create folders in specified directory.
How it works
There are two main functionality used in this sample :
(1) Get directory name values from Excel spreadsheet using Clipboard object
(2) Create folders using DirectoryInfo object.
(1) Get directory name values from Excel spreadsheet
VB.Net clipboard object allows you to get text from Clipboard object. Here is the code.
Use cells() array to buid a datatable and assign it to DataGridView as datasource.
(2) Create Folders
Once you have folder names in DataGridView, you can use it to create folders with DirectoryInfo() object.