private void OpenProjectFileForZipping() { SerializableTreeNode serializedTreeNode; if (applicationArgumentModel.IsFileOpenCase) { serializedTreeNode = projectSession.GetSerializableTreeNodeBaseOnProjectFile(applicationArgumentModel.FilePath); } else { serializedTreeNode = projectSession.GetSerializableTreeNodeBaseOnZipModel(); } this.zipModel = projectSession.ZipFileModel; if (IsDirectoryValidAndAccessible(this.zipModel.MainTargetLocationDirectory)) { String newArchiveName = zipModel.GetFullPathFileAndNameOfNewZipArchive; this.Text = this.Text + " => " + Path.GetFileName(newArchiveName); zipArchiving.NewArchiveName = newArchiveName; zipArchiving.SerializableTreeNode = serializedTreeNode; zipArchiving.ZipFileModelSource = zipModel; zipArchiving.CompressionLevelArchiving = CompressionLevel.BestCompression; zipArchiving.StartArchiving(); } else { MessageBox.Show(String.Format("The target location for archiving '{0}' is not accessible!", this.zipModel.MainTargetLocationDirectory), "Access Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); isWindowCanBeClose = true; btnStop.Enabled = false; } }
public ZipArchiving(String newArchiveName, ZipFileModel zipFileModel, SerializableTreeNode serializableTreeNode) { this.NewArchiveName = newArchiveName; this.ZipFileModelSource = zipFileModel; this.SerializableTreeNode = serializableTreeNode; PrepareEventsVariablesArgs(); }
public async Task <IActionResult> Upload([FromBody] ZipFileModel model) { try { var key = _configuration["Key"]; var IV = _configuration["IV"]; if (model.EncryptText.Length == 0) { throw new ArgumentNullException("Encrypted Source file size is zero."); } if (key == null || key.Length == 0) { throw new ArgumentNullException("Symmetric key is null."); } if (IV == null || IV.Length == 0) { throw new ArgumentNullException("Initilization Vector is null."); } byte[] encryptedByte = Convert.FromBase64String(model.EncryptText); AesCryptoServiceProvider aes = new AesCryptoServiceProvider(); aes.BlockSize = 128; aes.KeySize = 256; aes.Key = System.Text.ASCIIEncoding.ASCII.GetBytes(key); aes.IV = System.Text.ASCIIEncoding.ASCII.GetBytes(IV); aes.Padding = PaddingMode.PKCS7; aes.Mode = CipherMode.CBC; ICryptoTransform crypto = aes.CreateDecryptor(aes.Key, aes.IV); byte[] decrypted = crypto.TransformFinalBlock(encryptedByte, 0, encryptedByte.Length); var filepaths = System.Text.ASCIIEncoding.ASCII.GetString(decrypted); await _fileService.SaveFile(filepaths); return(Ok()); } catch (Exception ex) { throw (ex); } }
public void SaveProject(String fullFilePath, ZipFileModel customZipModel) { FileSerialization.SaveObjectToFile(Serialization.BinarySerialization, fullFilePath, customZipModel); }
public SerializableTreeNode GetSerializableTreeNodeBaseOnProjectFile(String fileFullPath) { ZipFileModel zipFileModel = OpenProjectSession(fileFullPath); return(zipFileModel.GetTreeViewZipFileSerializedStructure); }
public TreeNodeExtended GetTreeNodeZipDesignOnProjectFile(String fileFullPath) { ZipFileModel zipFileModel = OpenProjectSession(fileFullPath); return(zipFileModel.GetTreeViewZipFileStructure()); }
public ZipFileModel OpenProjectSession(String fileFullPath) { ZipFileModel = FileSerialization.LoadObjectToFile <ZipFileModel>(Serialization.BinarySerialization, fileFullPath); ZipFileModel.FilePath = fileFullPath; return(ZipFileModel); }
public void ClearProjectSession() { ZipFileModel = new ZipFileModel(); ApplicationArgumentModel = new ApplicationArgumentModel(new string[] { }); }