Ejemplo n.º 1
0
        public void ArchiveTest1()
        {
            var archive = new Archive("archive");

            archive.AddFile("123.doc");
            archive.AddFile("123.txt");
            archive.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the folder located at the specified path, and all child folders/files that it contains, to the recycle bin.
        /// </summary>
        public void AddFolder(string path)
        {
            if (linkedLibrary.FolderExists(path))
            {
                // Generate a file name for this deleted item.
                string recycleBinFolderName = CreateRandomFilename();

                // Create a new archive to contain the folder and it's child items.
                Archive  folderArchive = new Archive(recycleFolder.RootPath + "\\" + recycleBinFolderName, Archive.ArchiveMode.Create);
                string[] files         = linkedLibrary.GetFileList(path, "*", true);
                if (files.Length < 1)
                {
                    Output.Write(OutputTypes.Information, "The folder '" + path + "' does not contain any files, and will simply be deleted from the project folder.");
                }

                // Copy all of the child files to the archive.
                foreach (string file in files)
                {
                    byte[] fileData = linkedLibrary.ReadFile(file);
                    folderArchive.AddFile(file, fileData);
                }
                folderArchive.Close();

                RecycleBinEntry entry = new RecycleBinEntry();
                entry.Filename         = recycleBinFolderName;
                entry.OriginalPath     = path;
                entry.EntryType        = RecycleBinEntryType.Folder;
                entry.DeletedTimeStamp = DateTime.Now;
                entryTable.Add(entry);

                SaveEntryTable();
                OnStateChanged();
            }
        }
Ejemplo n.º 3
0
            public static void WriteScript(List <string> script, string fileName, int hMPQ)
            {
                string tempPath = Settings.FOLDER_PATH + @"temp\";

                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                System.IO.File.Create(tempPath + fileName).Dispose();
                StreamWriter writer = new StreamWriter(tempPath + fileName);

                foreach (string line in script)
                {
                    writer.WriteLine(line);
                }

                writer.Dispose();

                Archive.AddFile(tempPath + fileName, fileName, hMPQ);
                System.IO.File.Delete(tempPath + fileName);
            }
Ejemplo n.º 4
0
 public void CompressFile(string path)
 {
     archive.AddFile(path);
     mainWindow.emptyPanel.Visible = false;
 }