I'm working with asp.net project where user can upload files to server. I want to save the file with its original name, but if file with the same name already exists How can I generate a filename with a number in the parenthesis like windows does?

Files are uploaded to a particular folder and saved with its client side name itself. So, If a file named myimage.jpg is uploaded and a file with same name already exists in the server, I need to rename it to myimage(1).jpg or if 'myimage.jpg' to 'myimage(n).jpg' exists, I need to rename it to myimage(n+1).jpg.

What will be the best way to search for and generate such file names? My first guess was to use linq with regex over `DirectoryInfo.EnumerateFiles()`, but is that a good approach?