日期:2014-05-17 浏览次数:20865 次
///formLoad(object sender, EventArgs e)
OleDbConnection fswCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + conPath + ";");
if (fswCon.State == ConnectionState.Closed) fswCon.Open();
///private void watcher_Folder(object sender, FileSystemEventArgs e)
string reSql = @"select * from [Folder] where change='" + e.ChangeType.ToString() + "' and fullName='" + e.FullPath.ToString() + "'";
OleDbCommand reCmd = new OleDbCommand(reSql, fswCon);
OleDbDataReader reRead = reCmd.ExecuteReader();
if (!reRead.Read())
{
string deSql = @"delete from [Folder] where change='" + e.ChangeType.ToString() + "' and fullName='" + e.FullPath.ToString() + "'";
OleDbCommand deCmd = new OleDbCommand(deSql, fswCon);
try { deCmd.ExecuteNonQuery(); }
catch (System.Exception E) { MessageBox.Show(E.ToString()); }
finally { deCmd.Dispose(); }
}
reCmd.Dispose();
string crSql = @"insert into [Folder](change,dataName,changeTime,fileName,fileType,viewPath,fullPath) values ('" +
e.ChangeType.ToString() + "','" + dataName.ToString() + "','" + file.LastWriteTime.ToString() + "','" + Path.GetFileNameWithoutExtension(e.FullPath) + "','" +
Path.GetExtension(e.FullPath) + "','" + Path.GetDirectoryName(viewPath).ToString() + "','" + e.FullPath.ToString() + "')";
OleDbCommand crCmd = new OleDbCommand(crSql, fswCon);
try { crCmd.ExecuteNonQuery(); }
catch (System.Exception E) { MessageBox.Show(E.ToString()); }
finally { crCmd.Dispose(); }