I have an application that loops through files and moves them to their respective folder. if a file already exists in a folder, I need to append a letter to the filename:
myfilehere.txt will become
myfilehere_a.txt
and if it comes in again, myfilehere_b.txt
the error is on the increment. nothing goes past 'a'. i have tried all types of loops. below is a portion of the code I am having problems.
thanks in advance.
char letter = Char.Parse("a");
char letterEnd = Char.Parse("z");
for (char i = letter; i < letterEnd; i++)
{
//while (i<26)
//{
newfile = fname + "_" + letter.ToString() + extension;
if (!File.Exists(dupePathDir))
{
if (File.Exists(newfile))
{
string whatfile = fname + "_" + i.ToString() +extension;
return whatfile;
}
else
{
return newfile;
}
}
}
return null;