public static void RunEmbeddedFile(SqlConnection connection, SqlTransaction transaction, string resourceFileName) { string tempFolder = ""; if (resourceFileName.ToLower().EndsWith(".zip")) { tempFolder = ArchiveReader.ExtractArchive(resourceFileName); string[] files = Directory.GetFiles(tempFolder, "*.sql"); SortedDictionary <string, string> fileList = new SortedDictionary <string, string>(); foreach (string file in files) { fileList.Add(file, file); } foreach (string file in fileList.Values) { string[] scripts = ReadSQLFileSectionsFromFile(file); foreach (string sql in scripts) { ExecuteSQL(connection, transaction, sql); } } //Remove the temp folder if necessary try { System.IO.Directory.Delete(tempFolder, true); } catch (Exception ex) { } } else { string[] scripts = ReadSQLFileSectionsFromResource(resourceFileName); foreach (string sql in scripts) { ExecuteSQL(connection, transaction, sql); } } }