Class SftpFileSystem
- Namespace
- SshSharp.IO.Abstractions
- Assembly
- SshSharp.IO.Abstractions.dll
An System.IO.Abstractions.IFileSystem (System.IO.Abstractions) over SFTP: code written against System.IO.Abstractions.IFileSystem instead of
File, Directory and Path reads and writes files on an SSH server. Nothing is mounted, so only this application
sees them.
public sealed class SftpFileSystem : IFileSystem
- Inheritance
-
SftpFileSystem
- Implements
-
IFileSystem
- Inherited Members
Remarks
Paths are POSIX paths on the server, whatever OS this runs on: Path uses /, and relative paths are relative to
the current directory (System.IO.Abstractions.IDirectory.GetCurrentDirectory()), which starts as the login directory and is kept here, not on
the server. A \ is an ordinary character in a POSIX file name.
The abstraction is synchronous at heart: each synchronous call waits for its SFTP round trips, on the thread pool and bounded by
OperationTimeout; the asynchronous methods (ReadAllTextAsync and so on) do not block.
Errors are the exceptions System.IO throws: FileNotFoundException, DirectoryNotFoundException,
UnauthorizedAccessException and IOException (also for a failed session or connection).
SFTP has no creation times (the creation time reads as the last write time, and setting it does nothing), no file system
notifications, drives, version information, encryption or handles: FileSystemWatcher, DriveInfo,
FileVersionInfo, RandomAccess and the SafeFileHandle overloads throw NotSupportedException.
Constructors
- SftpFileSystem(SftpClient, SftpFileSystemOptions?)
A file system over
sftp.
Properties
- DirectoryInfo
A factory for the creation of wrappers for DirectoryInfo.
- DriveInfo
Not supported: SFTP has no drives (every factory method throws NotSupportedException).
- FileStream
A factory for the creation of wrappers for FileStream.
- FileSystemWatcher
Not supported: SFTP has no change notifications.
- FileVersionInfo
Not supported: version resources would mean reading every file.
- Path
POSIX path operations (
/), for the server's paths.
- RandomAccess
Not supported: it works on OS file handles, which remote files do not have.