public static int CreateDataBase(this MainForm main, CoreConfig config, string path) { string[] files = Directory.GetFiles(path, "*.bak"); string targetpath = config.DatabasePath; if (!Directory.Exists(targetpath)) { Directory.CreateDirectory(targetpath); } if (files != null) { MSSqlHelper sql = new MSSqlHelper(config.ConnectionString); if (sql.Open()) { int i = 0; foreach (string file in files) { try { sql.RestoreOrCreate(file, targetpath); i++; } catch (Exception e) { main.Error("创建数据库失败:" + file + "\n" + e.Message); break; } } return(i); } } return(0); }