using System; using System.IO; class Program { static void Main(string[] args) { try { using (StreamReader reader = new StreamReader("file.txt")) { // Read and discard the first line reader.ReadLine(); // Read the remaining content of the file string remaining = reader.ReadToEnd(); Console.WriteLine(remaining); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } }
using System; using System.IO; class Program { static void Main(string[] args) { try { using (FileStream stream = new FileStream("file.bin", FileMode.Open)) { // Seek to a specific position in the stream stream.Seek(100, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(stream)) { // Discard any buffered data from the old position reader.DiscardBufferedData(); // Read the content from the new position string remaining = reader.ReadToEnd(); Console.WriteLine(remaining); } } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } }This example opens a binary file called "file.bin" as a FileStream, seeks to position 100 using the Seek method, creates a StreamReader from the FileStream and discards any buffered data using the DiscardBufferedData method. Finally, it reads the remaining content of the file from the new position using the ReadToEnd method. These examples use the System.IO namespace provided by the .NET Framework.