I want to retrieve text files data from directory to particular database fields in sql. Here is a code:
try
{
FolderBrowserDialog fBrowser = new FolderBrowserDialog();
//create instance of folder browser to navigate to desired folder to compress files
DialogResult result = fBrowser.ShowDialog();
//process this if user clicks OK button
if (result == DialogResult.OK)
{
//string strPath stores chosen path
strPath = fBrowser.SelectedPath;
//put that path in the textbox1
txtSource.Text = strPath;
}
//set current directory to be the one you navigated to
//(this is also the folder that will store the compressed file)
Directory.SetCurrentDirectory(strPath);
//get contents of directory stored in "strPath"
DirectoryInfo di = new DirectoryInfo(strPath);
//create array that holds requested files from folder stored in "di" variable
DirectoryInfo[] rgFiles = di.GetDirectories("*.*");
//move through DirectoryInfo array and store in new array of fi
foreach (DirectoryInfo fi in rgFiles)
{
checkedListBox1.Items.Add(fi.Name); //add folders located into listbox
}
}
Here the directory contains no. of images and txt files, if we select the checklistbox then all the data from txt files should be added to particular sql database related to their datatypes. Can any one help me out