Beispiel #1
0
        public async Task RemoveFile(UserDataFile file)
        {
            var success = UserDataFiles.TryTake(out file);

            if (!success)
            {
                throw new FileNotFoundException(Strings.Vault_RemoveFile_Couldn_t_take_out_file_);
            }
            File.Delete(Path.Combine(EncryptedFolderPath, file.Header.TargetPath));
            if (file.Header.IsUnlocked)
            {
                await EliminateExtracted(file);
            }
        }
Beispiel #2
0
        public async Task AddFileAsync(string sourcePath, string path = "")
        {
            if (!File.Exists(sourcePath))
            {
                throw new FileNotFoundException(Strings.Vault_AddFileAsync_File_not_found, sourcePath);
            }

            var name    = Path.GetFileName(sourcePath);
            var newFile = new UserDataFile(UserDataHeader.Create(name, path));

            if (PlainNameAlreadyExists(newFile.Header.SecuredPlainName.PlainName))
            {
                FileAlreadyExists();
            }

            var destinationPath = Path.Combine(EncryptedFolderPath, newFile.Header.TargetPath);

            await WriteDecryptedAsync(newFile, sourcePath, destinationPath);

            UserDataFiles.Add(newFile);
        }