Skip to content
ConsoleMonster
Class

XdgTrash

ConsoleMonster.FileSystem

Namespace
ConsoleMonster.FileSystem
Assembly
ConsoleMonster
Implements
ITrash
Modifiers
sealed

The freedesktop.org trash used by Linux desktops (GNOME Files, Dolphin, gio trash): items move to Trash/files with a .trashinfo record in Trash/info, so file managers can restore them.

Inheritance

  • object
  • XdgTrash

Remarks

Items on the home volume go to $XDG_DATA_HOME/Trash (normally ~/.local/share/Trash). Items on another mounted volume go to that volume's .Trash/$uid or .Trash-$uid, as the specification asks, because a trash on another volume would turn a rename into a full copy.

Constructors

XdgTrash 2 overloads
public XdgTrash() #

Uses the current user's home trash and per-volume trash directories.

public XdgTrash(string homeTrash) #

Uses one trash directory for every item, such as a test folder or a portable install.

Parameters

homeTrash string required
The trash directory; files and info are created inside it.

Methods

public string? MoveToTrash(string path) #

Moves a file or folder to the trash. It never deletes permanently in place of trashing.

Parameters

path string required
The file or folder.

Returns

string? The item's location inside the trash when the platform reports it; otherwise null.

Exceptions

  • IOException – The item could not be trashed; nothing was deleted.

Properties

public string HomeTrash { get; } #

The home trash directory.

public string Name { get; } #

The name people know it by, such as Recycle Bin or Trash.

public bool IsAvailable { get; } #

Whether this machine has a trash this process can use. When false, ITrash.MoveToTrash always fails.