它的Load方法用於從數據庫中加載配置信息,其處理過程為
public void Load()
{
myWatchedPaths = null;
System.Collections.ArrayList paths = new System.Collections.ArrayList ();
using (System.Data.IDbCommand cmd = Util.DBConnection.CreateCommand())
{
cmd.CommandText = "Select ConfigName , ConfigValue From SystemConfig";
System.Data.IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string Name = Convert.ToString(reader.GetValue(0));
if (Name == null)
{
continue;
}
Name = Name.Trim().ToLower();
string Value = Convert.ToString(reader.GetValue(1));
if (Name.StartsWith("path"))
{
paths.Add(Value.Trim());
}
else if (Name == "logrenamed")
{
bolLogRenamed = Convert.ToBoolean(Value);
}
else if (Name == "logchanged")
{
bolLogChanged = Convert.ToBoolean(Value);
}
else if (Name == "logdeleted")
{
bolLogDeleted = Convert.ToBoolean(Value);
}
else if (Name == "logcreated")
{
bolLogCreated = Convert.ToBoolean(Value);
}
}
}
myWatchedPaths = (string[])paths.ToArray(typeof(string));
}
在該方法中程序查詢數據表SystemConfig中的配置項目名稱和數據,若項目 名稱以“path”開頭則為要監視的路徑,而配置項logrenamed,logchanged, logdeleted,logcreated分別表示是否監視文件目錄重命名,修改,刪除和新建等操作。