Interface IGorgonVirtualFile
A representation of a file from a physical file system.
Inherited Members
Namespace: Gorgon.IO
Assembly: Gorgon.FileSystem.dll
Syntax
public interface IGorgonVirtualFile : IGorgonNamedObject
Remarks
This represents the information for a file on a physical file system. This object only contains data about the file, and not the file itself. These files are read only and cannot be written into from the standard IGorgonFileSystem.
Users may retrieve a file from a IGorgonFileSystem via the GetFile(string) method. When the file has been returned to the user, they may call the OpenStream() method to read the contents of the file.
To create, update or delete a file from the IGorgonFileSystem, use an instance of the IGorgonFileSystemWriter<T> object and call the OpenStream(string, FileMode) method to create or update a file. Use the DeleteFile(string) method to delete a file.
Examples
This is an example of retrieving a file, and opening it for reading:
IGorgonFileSystem fileSystem = new GorgonFileSystem();
// Mount a directory for this file system.
fileSystem.Mount(@"C:\MyDirectory\", "/");
// Get the file.
IGorgonVirtualFile file = fileSystem.GetFile("/AFile.txt");
using (Stream stream = file.OpenStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
while (!reader.EndOfStream)
{
Console.WriteLine(reader.ReadLine());
}
}
}
Properties
| Edit this page View SourceBaseFileName
Property to return the file name without the extension.
Declaration
string BaseFileName { get; }
Property Value
Type | Description |
---|---|
string |
CreateDate
Property to return the file creation date.
Declaration
DateTime CreateDate { get; }
Property Value
Type | Description |
---|---|
DateTime |
Directory
Property to return the IGorgonVirtualDirectory that contains this file.
Declaration
IGorgonVirtualDirectory Directory { get; }
Property Value
Type | Description |
---|---|
IGorgonVirtualDirectory |
Extension
Property to return the file name extension.
Declaration
string Extension { get; }
Property Value
Type | Description |
---|---|
string |
FileSystem
Property to return the file system that owns this file.
Declaration
IGorgonFileSystem FileSystem { get; }
Property Value
Type | Description |
---|---|
IGorgonFileSystem |
FullPath
Property to return the full path to the file in the IGorgonFileSystem.
Declaration
string FullPath { get; }
Property Value
Type | Description |
---|---|
string |
LastModifiedDate
Property to return the last modified date.
Declaration
DateTime LastModifiedDate { get; }
Property Value
Type | Description |
---|---|
DateTime |
MountPoint
Property to return the mount point for this file.
Declaration
GorgonFileSystemMountPoint MountPoint { get; }
Property Value
Type | Description |
---|---|
GorgonFileSystemMountPoint |
Remarks
This will show where the file is mounted within the IGorgonFileSystem, the physical path to the file, and the IGorgonFileSystemProvider used to import the file information.
PhysicalFile
Property to return the physical file information for this virtual file.
Declaration
IGorgonPhysicalFileInfo PhysicalFile { get; }
Property Value
Type | Description |
---|---|
IGorgonPhysicalFileInfo |
Remarks
This will return information about the file queried from the physical file system.
Size
Property to return the uncompressed size of the file in bytes.
Declaration
long Size { get; }
Property Value
Type | Description |
---|---|
long |
Methods
| Edit this page View SourceOpenStream()
Function to open a stream to the file on the physical file system.
Declaration
Stream OpenStream()
Returns
Type | Description |
---|---|
Stream | The open Stream object. |
Remarks
This will open a Stream to the physical file for reading. Applications that open a stream to a file are responsible for closing the Stream when they are done.