GioSharp
| GioSharp | |
|---|---|
| Developer(s) | GNOME Project, Xamarin, and community contributors |
| Initial release |
2008 |
| Latest version | — |
| Programming language | C# |
| Operating system | Cross-platform |
| Platform | .NET, Mono |
| Type | System and I/O library bindings |
| License | GNU Lesser General Public License |
| Website | GitHub repository |
GioSharp is a set of C# bindings for the GIO library, a part of the GLib utility and object framework used throughout the GNOME platform.
It is included in the GtkSharp project and provides managed access to GIO’s high-level input/output, file system, networking, and application services.
Overview of GIO
GIO is a library within the GLib ecosystem that provides an abstract, object-oriented API for performing common system-level tasks in a cross-platform manner. It replaces older POSIX-style APIs with a more flexible, GObject-based design, supporting asynchronous operations, virtual file systems, and stream abstractions.
Key capabilities of GIO include:
- File and directory handling through GFile and GFileInfo
- Stream I/O (input/output, buffered streams, data streams)
- Asynchronous and cancellable operations
- Application and D-Bus integration (GApplication, GDBus)
- Network sockets and services (GSocket, GResolver, GNetworkMonitor)
- Volume and drive monitoring
GIO is used internally by GTK and other GNOME libraries to manage resources in a portable way.
GioSharp
GioSharp provides managed .NET bindings for the native GIO library. It exposes GIO’s APIs through idiomatic C# classes and interfaces, enabling .NET and Mono applications to access files, streams, network sockets, and interprocess communication mechanisms in a platform-independent manner.
Using GioSharp, developers can:
- Perform file and directory operations across different backends (local or remote)
- Handle asynchronous I/O using task-based programming in C#
- Communicate over D-Bus using managed objects and signals
- Build applications that use GApplication for single-instance management and session integration
- Monitor devices, volumes, and network changes
Relationship to other GtkSharp components
GioSharp complements other libraries in the GtkSharp ecosystem:
- GLibSharp – Provides the foundational GObject system and event loop used by GIO.
- GtkSharp – Uses GIO for file dialogs, resource handling, and application integration.
- GdkSharp – Can use GIO for stream and resource management in certain backends.
Version compatibility
GioSharp versions correspond to the GTK and GLib releases:
- **GioSharp 2.x** – Used with GTK 2 and GLib 2.x
- **GioSharp 3.x** – Updated for GTK 3 and GLib 2.40+
- **GioSharp 4.x** – Planned for GTK 4 and modern .NET runtimes
Usage example
A simple example of using GioSharp to read a file:
using Gio;
using GLib;
File file = File.NewForPath("example.txt");
string contents = file.LoadContents(null, out _);
Console.WriteLine(contents);
