Ejemplo n.º 1
0
        public void IsFileCheck()
        {
            string filePath = "TestFile.txt";

            try
            {
                FileAES_Utilities.SetVerboseLogging(true);

                File.WriteAllText(filePath, "Test");
                FAES_File faesFile = new FAES_File(filePath);

                if (!faesFile.IsFile())
                {
                    Assert.Fail("FAES_File incorrectly assumes a file is a folder!");
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
            finally
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compress (LGYZIP) an unencrypted FAES File.
        /// </summary>
        /// <param name="unencryptedFile">Unencrypted FAES File</param>
        /// <returns>Path of the unencrypted, LGYZIP compressed file</returns>
        public string CompressFAESFile(FAES_File unencryptedFile)
        {
            FileAES_IntUtilities.CreateEncryptionFilePath(unencryptedFile, "LGYZIP", out string tempRawPath, out _, out string tempOutputPath);

            if (unencryptedFile.IsFile())
            {
                using (ZipArchive zip = ZipFile.Open(tempOutputPath, ZipArchiveMode.Create))
                {
                    zip.CreateEntryFromFile(unencryptedFile.GetPath(), unencryptedFile.GetFileName());
                    zip.Dispose();
                }
            }
            else
            {
                FileAES_IntUtilities.DirectoryCopy(unencryptedFile.GetPath(), tempRawPath);

                ZipFile.CreateFromDirectory(tempRawPath, tempOutputPath);
            }

            return(tempOutputPath);
        }