MorkaLork Development

Interesting stuff I've picked up over the years...

Input/Output 4: FileInfo

2009-04-16 21:25:24 | 366 views | file info fileinfo access files several times

The Basics



The File class has static methods that can be conveniently used without having to have an instance of a File object; however, those methods always perform security checks that adversely affect performance. The FileInfo class provides similar methods for similar tasks, but without security checks. You should use FileInfo if you are going to access a file several times. Also, unlike File, methods in FileInfo are instance methods. To create a FileInfo object, pass a valid file path to its constructor. The Create method, for example, behaves like the Create method of the File class. For instance, the following code uses the FileInfo class to create a file:



FileInfo fileInfo = new FileInfo("C:/NextGen.txt");
FileStream fs = fileInfo.Create();



Source: http://www.ondotnet.com/pub/a/dotnet/2002/08/05/io.html?page=2


Article comments

Feel free to comment this article using a facebook profile.

I'm using facebook accounts for identification since even akismet couldn't handle all the spam I receive every day.