ExtractArchive() public static method

public static ExtractArchive ( string resourceFileName ) : string
resourceFileName string
return string
コード例 #1
0
        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);
                }
            }
        }