blankdev
July 18th, 2006, 09:15 PM
Hello guys, I'm creating a screenshot utility program which obviously takes screenshots. Anyways, I wanted to integrate a feature where one would specify a prefix, and then a number would be appended. For example, if my prefix were screen, and it was the third screen shot I took, it'd save the file as screen03, or something similar, I believe you get the point.
Anyways, I already know how to save and what not, I was just wondering if you guys had an idea as to how I'd accomplish this. I was thinking about doing some type of FileExists method (Is there one already?), and then I'd check if the first shot existed, if it did, then iterate through until the last one didn't exist, then I'd save it as that. I don't know if you guys understand my approach here, if you don't it's okay, but if you do, I'd be greatful to hear your comments.
Here's a rough, 'pseudo-code' visualization:
string file = "pic";
int num = 1;
while (true)
{
if (FileExists((file + num.ToString()) == true)
{
savefileas(file + num.ToString());
break;
}
}
Anyways, I already know how to save and what not, I was just wondering if you guys had an idea as to how I'd accomplish this. I was thinking about doing some type of FileExists method (Is there one already?), and then I'd check if the first shot existed, if it did, then iterate through until the last one didn't exist, then I'd save it as that. I don't know if you guys understand my approach here, if you don't it's okay, but if you do, I'd be greatful to hear your comments.
Here's a rough, 'pseudo-code' visualization:
string file = "pic";
int num = 1;
while (true)
{
if (FileExists((file + num.ToString()) == true)
{
savefileas(file + num.ToString());
break;
}
}