Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How to check if a type txt file is empty using C# with Visual Studio 2005?

I am developing a C# console application using Visual Studio 2005.

I use the following statement in my program:
if (File.Exists(errorFilePath))

Is there a way to open this txt type file and see if this file is empty?
I want to delete this file, if it is an empty file.
Avatar of Mez4343
Mez4343

Check the File.Lenth
if (File.Length==0)
                                Console.Writeline("File is empty.");
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial