I have a C# program where I am writing out data to a tab delimited file and I want the program to ascertain when the file size reaches 5MB and save it and start a new one.
In my code I have this:
FileInfo f = new FileInfo(opFolder + "\\" + opFile);
if (f != null)
//If length of file is greater than 5MB write it out and create a new version.
if(f.Length > 5242880)
//File save and start a new one here ...
For some unknown reason my file seems to keep on growing to around 50MB before a new one is started. Is this an error in the .Length property or am I missing something important!?
In the MSDN documentation it says the .Length property returns the file size in bytes??