Supported on Android, iOS, macOS, JVM, JS and WASM targets
Introduction
PlatformFile
is the core class in FileKit that provides a unified representation of files across all platforms. It abstracts away platform-specific file implementations and provides a consistent API for working with files in your Kotlin Multiplatform project.
Creating a PlatformFile
You can create aPlatformFile
instance in several ways:
Platform-specific constructors
Each platform also provides specific constructors:Properties
PlatformFile
provides several properties to access file information:
File operations
PlatformFile
provides methods for common file operations:
Working with directories
You can use theresolve
method or the /
operator to navigate through directories:
Converting to kotlinx-io
PlatformFile
provides built-in integration with kotlinx-io.
Example usage
Next steps
Read File
Read files as bytes, strings, or streams across platforms.
Write File
Write data to files with atomic operations and appending.
Image Utils
Compress, resize and save images with platform-specific optimizations.
File Utils
Access standard directories and common file operations.
Bookmark Data
Maintain persistent access to user-selected files across app restarts.