代码:
string GetVirPath(string FullName)
{
FullName = FullName.Replace(Server.MapPath( "ValueExpression/ "), " ");
FullName = FullName.Replace( "\\ ", "/ ");
return FullName;
}
private void loadNotes(string path)
{
DirectoryInfo mainDir = new DirectoryInfo(path);
//try
//{
//Response.Write( " <B> " + mainDir.Name + " </b> <br/> ");
string dbProvider = System.Configuration.ConfigurationManager.AppSettings[ "dbProvider "];
string dbPath;
string ConnectionString;
OleDbConnection con;
dbPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings[ "dbPath "]);
ConnectionString = dbProvider + "Data Source = " + dbPath;
con = new OleDbConnection(ConnectionString);
con.Open();
//遍历文件目录
foreach (FileInfo f in mainDir.GetFiles())
{
//增加文件GetVirPath(f.FullName)
//写入数据库
string cmdString = "select * from ValueProduce where FileName = ' " + GetVirPath(f.FullName) + " ' ";
OleDbCommand OleCmd = new OleDbCommand(cmdString, con);