the difference is that the File class have static methods for
handling files but FileInfo class have instance methods for
dealing with the files.
both File and FileInfo classes use 'Copy' to copy file to a
destination location.they use 'Create' to create files.they
use 'Delete' for deleting a file.they use Exists to check
file existance.but File class uses 'Exists' as method and
FileInfo class uses 'Exists' as property.they use 'Move' for
moving the file.they both use 'Open' for opening FileStream to
file.
FileInfo class includes a constructor which takes one parameter
of a string(contains the path of the file).the path to file may
be totally qualified path or relative.when making FileInfo object
the file is not needed to be existed.
following shows a example to construct a FileInfo obj-
FileInfo file1 = new FileInfo("d:\\tempo\\csharp.txt");//totally
FileInfo file2 = new FileInfo("\\datab\\Data.xml");//Relational
FileInfo file3 = new FileInfo(@"\datab\myDataFile.xml");
//Using a verbatim string
some valuable properties of the FileInfo class are follows-
1.Attributes
2.DirectoryName
3.CreationTime
4.Exists
5.FullName
6.Name
7.Length
because the File class includes static methods,you may conduct
many file functions besides making an instance of file as shown-
//for Copying a file
File.Copy(@"c:\tempodir\csharp.txt",@"e:\tempodir\csharp.txt");
//for creating file
File.Create(@"d:\tempodir\newdocument.txt");