示例#1
0
        private List <string> InitNewModFiles(string sourcePath)
        {
            List <string> list = new List <string>();

            try
            {
                string tempPath = Path.GetTempPath() + "smm";
                if (Directory.Exists(tempPath))
                {
                    Directory.Delete(tempPath, true);
                }
                ZipFile.ExtractToDirectory(sourcePath, tempPath);
                Console.WriteLine("已经 " + sourcePath + "解压至" + tempPath);
                string nTempPath = Path.GetTempPath() + @"smm_nFiles";
                Directory.CreateDirectory(nTempPath);
                foreach (string filePath in
                         Directory.GetFiles(tempPath, "*", SearchOption.AllDirectories))
                {
                    if (PathOperation.IsModFilePath(filePath))
                    {
                        string nPath = PathOperation.NormolizeModFilePath(filePath);
                        Console.WriteLine("标准路径为:" + nPath);
                        list.Add(nPath);
                        Directory.CreateDirectory(Path.GetDirectoryName(nTempPath + "\\" + nPath));
                        File.Copy(filePath, nTempPath + "\\" + nPath, true);
                    }
                }
                File.Delete(sourcePath);
                if (list.Count > 0)
                {
                    ZipFile.CreateFromDirectory(nTempPath,
                                                sourcePath, CompressionLevel.Fastest, false);
                }
                Directory.Delete(tempPath, true);
                Directory.Delete(nTempPath, true);
                return(list);
            }
            catch (Exception e)
            {
                ExceptionHandler.ShowError(e, "无法初始化Mod信息");
                return(list);
            }
        }