private string StoreFileInRegistry(string path, string regkey) { byte[] data = _fileHandler.GetFile(path); if (data == null) { return("Error: Could not find the specified file."); } data = _encoder.Encode(data); return(_registryHandler.SaveFile(data, regkey) ? $"The file {Path.GetFileName(path)} has been stored successfully." : "Error: Could not save the specified file."); }
private string RestoreFileFromRegistry(string path, string regkey) { if (File.Exists(path)) { return("Error: The specified file already exists."); } byte[] data = _registryHandler.GetFile(regkey); if (data == null) { return("Error: Could not find the specified value in the registry."); } data = _encoder.Decode(data); return(_fileHandler.SaveFile(data, path) ? $"The file {Path.GetFileName(path)} has been restored successfully." : "Error: Could not restore the file."); }