none
Performance of System.IO.File vs System.IO.FileStream RRS feed

  • Question

  • Suppose I use C# 2010.

    I tried to use File class and FileStream class to read data from a large file or write a large amount of data into a file.

    Which class offers me a better performance and why?

    Thanks.

    Tuesday, April 2, 2013 7:52 AM

Answers

  • File is just a static wrapper around FileStream and the writers.  Performance will be the same.  The bigger issue is how big your files are.  If you are trying to write to large files then you'll be using a writer (StreamWriter/BinaryWriter) to write the data.  If you need to insert data at the end of a binary file you'll be using BinaryWriter.  If you are inserting text at the end of a file then you could use File.AppendAllText.

    Michael Taylor - 4/2/2013
    http://msmvps.com/blogs/p3net

    Tuesday, April 2, 2013 5:39 PM
    Moderator