i have created screenshot program , working great. problem is, not sure how can make screenshots saved appending numbers.
example: screenshot 1, screenshot 2, screenshot 3, screenshot 4, etc.
obviously applied other files being saved. ideas? thank you.
here method use case. pass in string "screenshot" , find lowest available filename in format of "screenshot [number]" (or "screenshot" if there aren't already):
private string getuniquename(string name, string folderpath) { string validatedname = name; int tries = 1; while (file.exists(folderpath + validatedname)) { validatedname = string.format("{0} [{1}]", name, tries++); } return validatedname; } (note: simplified version doesn't take file extensions account).
Comments
Post a Comment