The files names are incorrect i want to give to each file name a number and increasing the numbers by one.
at the top
private int counter = 0;
when downloading and saving the files
for(int i = 0; i < 10; i )
{
await DownloadFiles(downloadLinks[i], testFolder "\\test" counter 1.ToString() ".gif");
counter ;
}
The result is
test01 test11 test21 test31 test41 test51 test61
and i want the files names to be
test1 test2 test3 test4 test5 test6
CodePudding user response:
You are converting 1 to string (that way you cannot add it to the counter), put them in braces or it is much cleaner to add them before you are placing it as an argument.
int counter = 0;
for(var i = 0; i < 10; i )
{
await DownloadFiles(downloadLinks[i], testFolder "\\test" (counter 1) ".gif");
counter ;
}
alternatively you could use Path.Combine()
and string interpolation, to make it much cleaner:
int counter = 0;
for(var i = 0; i < 10; i )
{
await DownloadFiles(downloadLinks[i], Path.Combine(testFolder, $"test{counter 1}.gif"));
counter ;
}