Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

VFile Class

Namespace: Rebex.IO
Assembly: Rebex.FileSystem.dll (version 7.0.9119)

This class contains static methods that work with virtual file system files. This class provides methods that are functionally similar to the standard .NET File methods.

Syntax
public static class VFile
Inheritance
Object
VFile
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Examples
//Create a built-in or custom VFS provider 
var memoryProvider = new MemoryFileSystemProvider()
//Save the root path
var memoryProviderRootPath = memoryProvider.GetRootVDirectoryInfo().FullName;
//Create 'file.dat' file in the root directory.
using (var myFile = VFile.Create(Path.Combine(memoryProviderRootPath, "file.dat")))
{
  //Write data to the file
  myFile.Write(myData, 0, myData.Length);
}

Methods

Name Description
AppendAllLines(String, IEnumerable<String>)

Method appends contents to a file identified by the path.

AppendAllLines(String, IEnumerable<String>, Encoding)

Method appends contents to a file identified by the path and using a encoding.

AppendAllLinesAsync(String, IEnumerable<String>, Encoding, CancellationToken)

Method appends contents to a file identified by the path and using a encoding.

AppendAllLinesAsync(String, IEnumerable<String>, CancellationToken)

Method appends contents to a file identified by the path.

AppendAllText(String, String)

Method appends contents to a file identified by the path.

AppendAllText(String, String, Encoding)

Method appends contents to a file identified by the path and using a encoding.

AppendAllTextAsync(String, String, Encoding, CancellationToken)

Method appends contents to a file identified by the path and using a encoding.

AppendAllTextAsync(String, String, CancellationToken)

Method appends contents to a file identified by the path.

AppendText(String)

Method returns an instance of the StreamWriter that appends data to the file identified by the path.

Copy(String, String)

Method copies a file identified by the sourceFileName to the location denoted by the destFileName.

Copy(String, String, Boolean)

Method copies a file identified by the sourceFileName to the location denoted by the destFileName.

Create(String)

Method returns read/write instance of the VFileStream for a file identified by the path. A caller must dispose the returned stream to ensure that the data written to the stream are persisted.

Create(String, Int32)

Method returns read/write instance of the VFileStream for a file identified by the path. A caller must dispose the returned stream to ensure that the data written to the stream are persisted.

Create(String, Int32, FileOptions)

Method returns read/write instance of the VFileStream for a file identified by the path. A caller must dispose the returned stream to ensure that the data written to the stream are persisted.

CreateText(String)

Method returns StreamWriter for a file identified by the path. A caller must dispose the returned StreamWriter to ensure that the data written to the StreamWriter are persisted.

Delete(String)

Deletes a file identified by the path.

Exists(String)

Method returns true when a file exists on the given path; otherwise returns false.

GetAttributes(String)

Method returns FileAttributes for a file identified by the path.

GetCreationTime(String)

Method returns the creation date and time of a file identified by the path.

GetCreationTimeUtc(String)

Method returns the creation date and time of a file identified by the path. The time is expressed in the UTC format.

GetLastAccessTime(String)

Method returns the last access date and time of a file identified by the path.

GetLastAccessTimeUtc(String)

Method returns the last access date and time of a file identified by the path. The time is expressed in the UTC format.

GetLastWriteTime(String)

Method returns the last write date and time of a file identified by the path.

GetLastWriteTimeUtc(String)

Method returns the last write date and time of a file identified by the path. The time is expressed in the UTC format.

Move(String, String)

Method moves a file identified by the sourceFileName to the location denoted by the destFileName.

Open(String, FileMode)

Method returns an instance of the VFileStream for a file identified by the path and required mode. A caller must dispose the returned stream.

Open(String, FileMode, FileAccess)

Method returns an instance of the VFileStream for a file identified by the path, required mode and requested access. A caller must dispose the returned stream.

Open(String, FileMode, FileAccess, FileShare)

Method returns an instance of the VFileStream for a file identified by the path, required mode and requested access. A caller must dispose the returned stream.

OpenRead(String)

Method returns an instance of the read-only VFileStream for a file identified by the path. A caller must dispose the returned stream. Calling the method is equivalent to calling the method Open(String, FileMode, FileAccess) with arguments Open(path, FileMode.Open, FileAccess.Read).

OpenText(String)

Method returns an instance of the StreamReader for a file identified by the path. A caller must dispose the returned StreamWriter.

OpenWrite(String)

Method returns an instance of the write-only VFileStream for a file identified by the path. A caller must dispose the returned stream. Calling the method is equivalent to calling the method Open(String, FileMode, FileAccess) with arguments Open(path, FileMode.OpenOrCreate, FileAccess.Write).

ReadAllBytes(String)

Method returns a byte array that contains the binary content of a file identified by the path.

ReadAllBytesAsync(String, CancellationToken)

Method returns a byte array that contains the binary content of a file identified by the path.

ReadAllLines(String)

Method returns a string array that contains all lines from a text file identified by the path.

ReadAllLines(String, Encoding)

Method returns a string array that contains all lines from a text file identified by the path. All lines are read using the provided encoding.

ReadAllLinesAsync(String, Encoding, CancellationToken)

Method returns a string array that contains all lines from a text file identified by the path.

ReadAllLinesAsync(String, CancellationToken)

Method returns a string array that contains all lines from a text file identified by the path.

ReadAllText(String)

Method returns a String that contains text content of a file identified by the path.

ReadAllText(String, Encoding)

Method returns a String that contains text content of a file identified by the path. Content of the file is read using the provided encoding.

ReadAllTextAsync(String, Encoding, CancellationToken)

Method returns a String that contains text content of a file identified by the path. Content of the file is read using the provided encoding.

ReadAllTextAsync(String, CancellationToken)

Method returns a String that contains text content of a file identified by the path.

ReadLines(String)

Method returns an enumerable that iterates through the lines from a text file identified by the path.

ReadLines(String, Encoding)

Method returns an enumerable that iterates through the lines from a text file identified by the path. All lines are read using the provided encoding.

Replace(String, String, String)

Method copies content of the sourceFileName to the destinationFileName and deletes sourceFileName. In other words, content of the destinationFileName is replaced by the content of the sourceFileName. When the destinationBackupFileName is not null then the original (to be replaced) content of the destinationFileName is stored in the destinationBackupFileName.

Replace(String, String, String, Boolean)

Method copies content of the sourceFileName to the destinationFileName and deletes sourceFileName. In other words, content of the destinationFileName is replaced by the content of the sourceFileName. When the destinationBackupFileName is not null then the original (to be replaced) content of the destinationFileName is stored in the destinationBackupFileName.

SetAttributes(String, FileAttributes)

Method sets fileAttributes for a file identified by the path.

SetCreationTime(String, DateTime)

Method sets the creation date and time of a file identified by the path.

SetCreationTimeUtc(String, DateTime)

Method sets the creation date and time of a file identified by the path. The time is expressed in the UTC format.

SetLastAccessTime(String, DateTime)

Method sets the last access date and time of a file identified by the path.

SetLastAccessTimeUtc(String, DateTime)

Method sets the last access date and time of a file identified by the path.

SetLastWriteTime(String, DateTime)

Method sets the last write date and time of a file identified by the path.

SetLastWriteTimeUtc(String, DateTime)

Method sets the last write date and time of a file identified by the path. The time is expressed in the UTC format.

WriteAllBytes(String, Byte[])

Method writes the bytes to a file identified by the path.

WriteAllBytesAsync(String, Byte[], CancellationToken)

Method writes the bytes to a file identified by the path.

WriteAllLines(String, IEnumerable<String>)

Method writes the contents to a file identified by the path.

WriteAllLines(String, IEnumerable<String>, Encoding)

Method writes the contents to a file identified by the path and using the encoding.

WriteAllLines(String, String[])

Method writes the contents to a file identified by the path.

WriteAllLines(String, String[], Encoding)

Method writes the contents to a file identified by the path and using the encoding.

WriteAllLinesAsync(String, IEnumerable<String>, Encoding, CancellationToken)

Method writes the contents to a file identified by the path and using the encoding.

WriteAllLinesAsync(String, IEnumerable<String>, CancellationToken)

Method writes the contents to a file identified by the path.

WriteAllText(String, String)

Method writes the contents to a file identified by the path.

WriteAllText(String, String, Encoding)

Method writes the contents to a file identified by the path and using the encoding.

WriteAllTextAsync(String, String, Encoding, CancellationToken)

Method writes contents to a file identified by the path and using the encoding.

WriteAllTextAsync(String, String, CancellationToken)

Method writes contents to a file identified by the path.

See Also

VDirectoryInfo
VFileInfo
VDirectory
MemoryFileSystemProvider
LocalFileSystemProvider
MountCapableFileSystemProvider
ReadWriteFileSystemProvider
ReadOnlyFileSystemProvider
In This Article
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies