Nevron Open Vision Documentation

The NFile class contains properties and methods for working with files in a platform independent way. In most cases you will have to use one of the static methods of the NFile class, but whenever necessary you can also create an NFile instance by using the IO Service in order to get access to additional functionality like file size, file attributes, creation time, last access time, last write time and so on.

The methods of the NFile class are organized into two major categories:

File System

These following static methods of the NFile class aids you in working with the file system:

All of these methods are also available as instance methods of the NFile class.

The NFile class provides the following properties:

Working with Streams

The following static methods of the NFile class lets you create, read and write files:

The following example demonstrates how to read fully an UTF8 encoded text file:

Read File
Copy Code
string text;

using (Stream stream = NFile.OpenRead(@"C:\Documents\MyFile.txt"))
    byte[] data = NStreamHelpers.ReadToEnd(stream);
    text = NEncoding.UTF8.GetString(data);
Working with Files

NFile provides the following static files to work directly with files:

For example to read a file as string using the default UTF-8, you can use the following line of code:

Read File
Copy Code
string text = NFile.ReadAllText(@"C:\Documents\MyFile.txt");
See Also
Send Feedback