一、内容
本文对前面所提及的相关信息做一些小设计
二、代码
cs
public void Open_File(string FileNmae)
{
Process.Start("explorer.exe", FileNmae);
}
public void Connect_Excel()
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="路
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
string sql = "Select * from [110KV-下节油箱三维模型设计$]";
OleDbDataAdapter adapter = new OleDbDataAdapter(sql, connection);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
connection.Close();
DataTableCollection tableCollection = dataset.Tables;
DataTable table = tableCollection[0];
DataRowCollection rowCollection = table.Rows;
foreach (DataRow row in rowCollection)
{
for (int i = 0; i < 8; i++)
{
name1[w] = Convert.ToString(row[0]);
name2[w] = Convert.ToString(row[1]);
name3[w] = Convert.ToString(row[2]);
name4[w] = Convert.ToString(row[3]);
}
w++;
count++;
}
}//连接EXCEL
public void Move_Part(string sourceFolderPath) //转移
{
string destinationFolderPath = "路径";
string searchPattern = "*.*";
// 获取源文件夹中所有匹配搜索模式的文件列表
string[] filess = Directory.GetFiles(sourceFolderPath, searchPattern);
foreach (string file in filess)
{
string fileName = Path.GetFileName(file);
string destinationFile = Path.Combine(destinationFolderPath, fileName);
File.Copy(file, destinationFile, true); // 第三个参数为true时表示可以覆盖同名文件
}
}
这三个一起是,打开我们设定的模型,读取EXCEL表中内容,将模型转移