public void RenameFile(UserDataFile file, string name) { if (name.Contains("/")) { throw new NotANameException(Strings.Vault_RenameFile_Argument_isn_t_a_name); } var dir = NDirectory.GetPathParentDir(file.Header.SecuredPlainName.PlainName); MoveFile(file, dir + name); }
public async Task EliminateExtracted(UserDataFile file) { if (!file.Header.IsUnlocked) { throw new FileNotUnlockedException(); } var plainTextPath = file.Header.SecuredPlainName.PlainName; var path = Path.Combine(UnlockedFolderPath, plainTextPath); if (!File.Exists(path)) { file.Header.IsUnlocked = false; throw new FileNotFoundException(Strings.Vault_EliminateExtracted_Decrypted_file_was_not_found, plainTextPath); } await NFile.Purge(path); file.Header.IsUnlocked = false; var parentDir = Path.Combine(UnlockedFolderPath, NDirectory.GetPathParentDir(plainTextPath)); NDirectory.DeleteDirIfEmpty(parentDir, UnlockedFolderName); }
public static string GetRelativePathToFile(string relativeTo, string path) { var relativePath = Path.GetRelativePath(relativeTo + "/..", path); return(NDirectory.GetPathParentDir(relativePath)); }