public ClientProto.StatusResponse MoveFile(ClientProto.DoublePath doublePath) { try { string path = doublePath.Fullpath; string newPath = doublePath.Newpath; string oldName = TraverseFileSystem(path); Folder oldFolder = CurrentDirectory; string newName = TraverseFileSystem(newPath); FileSystem.File toBeMoved = oldFolder.files[oldName]; oldFolder.files.Remove(oldName); toBeMoved.name = newName; toBeMoved.path = $"{CurrentDirectory.path}/{newName}"; CurrentDirectory.files.Add(newName, toBeMoved); SaveFileDirectory(); return(new ClientProto.StatusResponse { Type = ClientProto.StatusResponse.Types.StatusType.Success }); } catch (Exception e) { Console.WriteLine(e.Message); return(new ClientProto.StatusResponse { Type = ClientProto.StatusResponse.Types.StatusType.Fail, Message = "Internal Server Failure" }); } }
public override Task <ClientProto.StatusResponse> MoveFile(ClientProto.DoublePath path, ServerCallContext context) { return(Task.FromResult(Program.Database.MoveFile(path))); }