using System.IO; string filePath = "C:/example.txt"; if (File.Exists(filePath)) { using (IFile file = File.OpenRead(filePath)) { //read file contents } }
using System.IO; string filePath = "C:/example.txt"; using (IFile file = File.Create(filePath)) { byte[] data = Encoding.UTF8.GetBytes("Hello World!"); file.Write(data, 0, data.Length); }This code creates a new file and writes data to it using IFile. The IFile interface is part of the System.IO namespace in the .NET Framework.