テキスト ファイル データをディレクトリから SQL の特定のデータベース フィールドに取得したいと考えています。コードは次のとおりです。
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
}
}
ここで、ディレクトリには no が含まれています。画像と txt ファイルの場合、チェックリスト ボックスを選択すると、txt ファイルからのすべてのデータが、それらのデータ型に関連する特定の SQL データベースに追加されます。誰でも私を助けることができます