I have a C# winform application that is outputting to excel files.
Let’s say the name format of the file name is: Output1.xlsl
I would like to have the output saved to another sequential file on each button click/execution.
So next it would be Output2.xlsl, Output3.xlsl… etc.
How to check that, I know of checking if the file exists, but how to check for the numbering?
FileInfo newExcelFile = new FileInfo(@"Output1.xlsx");
if (newExcelFile.Exists)
{
...
}
You could use this loop and
File.ExistswithPath.Combine:In general the static
Filemethods are more efficient than always creating aFileInfoinstance.