Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string AvailableFileName(string fileName)
- {
- if (!File.Exists(fileName))
- {
- return fileName;
- }
- string str = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName));
- string extension = Path.GetExtension(fileName);
- int num = 1;
- while (true)
- {
- string path = string.Format("{0}({1}){2}", str, num, extension);
- if (!File.Exists(path))
- {
- return path;
- }
- num++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment