Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private string GetNextFileName(string fileName)
- {
- int index = 1;
- string nextName = $"{fileName}_{index}.png";
- while (File.Exists(nextName))
- {
- nextName = $"{fileName}_{++index}.png";
- }
- return nextName;
- }
- private string GetNextFileName(string fileName)
- {
- int i = 1;
- string nextName = $"{fileName}_{i}.png";
- for (; i < 100; ++i)
- {
- if (!File.Exists(nextName))
- {
- return nextName;
- }
- nextName = $"{fileName}_{i}.png";
- }
- throw new ApplicationException("Unable to get free filename");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement