1、DataTable与DataRow[]互转
//DataTable 转DataRow[]
DataRow[] dtRow = dt.Select();
//DataRow[] 转DataTable
DataTable dt02 = dtRow .CopyToDataTable();
2、对文件是否存在的一些操作
string folderPath = @"C:\Users\Desktop\test";
string filePath = @"C:\Users\Desktop\test.txt";
try
{
if (System.IO.Directory.Exists(folderPath) == false)
{
System.IO.Directory.CreateDirectory(folderPath);
}
MessageBox.Show("创建成功");
if (System.IO.File.Exists(filePath) == false)
{
System.IO.File.CreateText(filePath);
}
MessageBox.Show("创建成功");
}
catch (Exception ex)
{
MessageBox.Show("创建失败");
throw ex;
}