internal string CreateAppPackage() { if (!this.SaveProject()) { return(string.Empty); } List <string> fileList = new List <string>(); foreach (var file in GetImageFiles()) { fileList.Add(file); } // Install to local RegistryKey subKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\上海速学信息科技有限公司(SoonLearning.com)\速学应用平台"); if (subKey != null) { string appPath = subKey.GetValue("Path") as string; if (!string.IsNullOrEmpty(appPath)) { string dataPath = System.IO.Path.Combine(appPath, @"data\Assessment"); if (!Directory.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } string targetPath = System.IO.Path.Combine(dataPath, this.App.Id); if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } string targetImagePath = System.IO.Path.Combine(targetPath, "Images"); if (!Directory.Exists(targetImagePath)) { Directory.CreateDirectory(targetImagePath); } foreach (string imageFile in fileList) { try { File.Copy(imageFile, Path.Combine(targetImagePath, Path.GetFileName(imageFile))); } catch { } } try { File.Copy(this.ProjectFile, Path.Combine(targetPath, Path.GetFileName(this.ProjectFile))); } catch { } } } // fileList.Add(this.ProjectFile); // string[] imageFiles = Directory.GetFiles(this.ImagePath, "*.*"); // fileList.AddRange(imageFiles); string folder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (Helper.Is64BitOS()) { SevenZipCompressor.SetLibraryPath(System.IO.Path.Combine(folder, "ThirdParty\\7z\\7z64.dll")); } else { SevenZipCompressor.SetLibraryPath(System.IO.Path.Combine(folder, "ThirdParty\\7z\\7z.dll")); } SevenZipCompressor cmp; try { cmp = new SevenZipCompressor(); cmp.ArchiveFormat = OutArchiveFormat.Zip; cmp.CompressionLevel = CompressionLevel.Normal; cmp.CompressionMode = CompressionMode.Create; cmp.FastCompression = false; cmp.TempFolderPath = this.DataPath; string archiveFile = System.IO.Path.Combine(this.DataPath, this.App.Id + ".zip"); if (System.IO.File.Exists(archiveFile)) { System.IO.File.Delete(archiveFile); } if (fileList.Count > 0) { cmp.CompressFilesEncrypted(archiveFile, getTempPath().Length, "$L&%$D123@3$5^7*", fileList.ToArray()); cmp.CompressionMode = CompressionMode.Append; } cmp.CompressFilesEncrypted(archiveFile, Path.GetDirectoryName(this.ProjectFile).Length, "$L&%$D123@3$5^7*", new string[] { this.ProjectFile }); foreach (string file in fileList) { try { File.Delete(file); } catch { } } string slpFile = Path.Combine(ProjectMgr.Instance.DataPath, this.App.Id + ".slp"); PackageCreator.CreateTeachAppPackage(this.App.Id, this.App.Name, this.App.Description, this.App.Thumbnail, this.App.Type, this.App.SubType, this.App.CreateDate, this.App.Creator, this.App.CreatorLogo, this.App.CreatorWebsite, archiveFile, slpFile); return(slpFile); } catch (Exception ex) { Debug.Assert(false, ex.Message); } return(string.Empty); }