Class FileStream
A stream that is backed by a named file on the filesystem
public sealed class FileStream : Stream, IDisposable
- Inheritance
-
FileStream
- Implements
- Inherited Members
- Extension Methods
Constructors
FileStream(string, FileAccess, FileMode)
Creates a new FileStream for a specified file name, access, and mode
public FileStream(string fileName, FileAccess access, FileMode mode)
Parameters
fileNamestringThe name of the file to open
accessFileAccessThe FileAccess value representing the access mode
modeFileModeThe FileMode value representing the file mode
Remarks
On Android, this can be used to open "content://" URIs. As a fallback, this will transparently open a matching fileName in the app's assets.
Exceptions
- SdlException
The FileStream could not be created (check TryGet(out string?) for more information)
- ArgumentException
The combination of
accessandmodeis invalid
FileStream(string, FileAccess, FileMode, FileKind)
Creates a new FileStream for a specified file name, access, mode, and kind
public FileStream(string fileName, FileAccess access, FileMode mode, FileKind kind)
Parameters
fileNamestringThe name of the file to open
accessFileAccessThe FileAccess value representing the access mode
modeFileModeThe FileMode value representing the file mode
kindFileKindThe FileKind value representing the file kind
Remarks
On Android, this can be used to open "content://" URIs. As a fallback, this will transparently open a matching fileName in the app's assets.
Exceptions
- SdlException
The FileStream could not be created (check TryGet(out string?) for more information)
- ArgumentException
The combination of
access,mode, andkindis invalid
FileStream(string, string)
Creates a new FileStream for a specified file name and mode string
public FileStream(string fileName, string modeString)
Parameters
fileNamestringThe name of the file to open
modeStringstringThe mode string to use when opening the file
Remarks
The mode strings used by this method are roughly the same as the ones used by the C standard library's fopen function.
You can use TryGetModeString(FileAccess, FileMode, out string?) or TryGetModeString(FileAccess, FileMode, FileKind, out string?) to construct valid mode strings.
On Android, this can be used to open "content://" URIs. As a fallback, this will transparently open a matching fileName in the app's assets.
Exceptions
- SdlException
The FileStream could not be created (check TryGet(out string?) for more information)
Properties
AndroidAAsset
Gets the pointer to the Android NDK AAsset that the FileStream is using to access the filesystem
public nint AndroidAAsset { get; }
Property Value
- nint
The pointer to the Android NDK
AAssetthat the FileStream is using to access the filesystem. This can be cast to an Android NDKAAsset*.
Remarks
If SDL uses some other method to access the filesystem, this property will not be set and returns default(nint).
- See Also
FileDescriptor
Gets the file descriptor number that the FileStream is using to access the filesystem
public int FileDescriptor { get; }
Property Value
- int
The file descriptor number that the FileStream is using to access the filesystem. This is a C file descriptor number.
- See Also
StdioFile
Gets the pointer to the C standard library FILE that the FileStream is using to access the filesystem
public nint StdioFile { get; }
Property Value
- nint
The pointer to the C standard library
FILEthat the FileStream is using to access the filesystem. This can be cast to a C standard libraryFILE*.
Remarks
If SDL uses some other method to access the filesystem, this property will not be set and returns default(nint).
NOTE: The value of this property is highly dependent on the C standard library and the compiler the underlying native SDL library was built with. Using that value without knowing these settings or using it on differing platforms may lead to at least undefined behavior or even result in a crash! Do not rely on the value of this property unless you really know what you are doing.
- See Also
WindowsHandle
Gets the Windows HANDLE that the FileStream is using to access the filesystem
public nint WindowsHandle { get; }
Property Value
- nint
The Windows
HANDLEthat the FileStream is using to access the filesystem. This can be cast to a WindowsHANDLE.
Remarks
If SDL uses some other method to access the filesystem, this property will not be set and returns default(nint).
Methods
TryGetModeString(FileAccess, FileMode, FileKind, out string?)
public static bool TryGetModeString(FileAccess access, FileMode mode, FileKind kind, out string? modeString)
Parameters
accessFileAccessThe FileAccess value representing the access mode
modeFileModeThe FileMode value representing the file mode
kindFileKindThe FileKind value representing the file kind
modeStringstringThe resulting mode string, when this method returns
true; otherwise,null
Returns
Remarks
A mode string constructed by this method is roughly the same as the ones used by the C standard library's fopen function.
TryGetModeString(FileAccess, FileMode, out string?)
public static bool TryGetModeString(FileAccess access, FileMode mode, out string? modeString)
Parameters
accessFileAccessThe FileAccess value representing the access mode
modeFileModeThe FileMode value representing the file mode
modeStringstringThe resulting mode string, when this method returns
true; otherwise,null
Returns
Remarks
A mode string constructed by this method is roughly the same as the ones used by the C standard library's fopen function.