I am fairly new to C# and would like to ask how can I set a certain file limit to a comma-separated file. The scenario that I would be using them is as follows.
- Before I write the CSV output file, I need to check if there is an existing CSV file or not on a specific path/drive
- While the method is running, how can I make it stop writing before it exceeds its file size limit (preferably 500 MB worth of file size of CSV)?
This is currently the code I am using:
if (!File.Exists(newFileName))
{
File.WriteAllText(newFileName, clientheader);
//File.WriteAllText(logFileName, logfileheader);
}
else
{
File.AppendAllText(newFileName, clientheader);
// File.AppendAllText(logFileName, logfileheader);
}