hi ihave many files like
File.txt
anotherfile.txt
Log.txt . Etc...
And i want to rename these files into something like this
File1.txt
File2.txt
File3.txt . Etc
So how can i do this in c#
Thank you for your help

Are these files in one folder? If so, you can get all files from this folder into a FileInfo[] (you need fileInfo, because you need a full path, so set files back where they were before renaiming).
Then you do some additional code of renaiming and use Move method for an actual renaiming:

string path =@"C:\MyFolder";
            FileInfo[] files = new DirectoryInfo(path).GetFiles("*.txt");
            for (int i = 0; i < files.Length; i++)
            {
                string newFile = String.Format("{0}{1}.{2}", "File", (i + 1), "txt");
                string fullNewPath = files[i].DirectoryName;
                File.Move(files[i].FullName, Path.Combine(fullNewPath, newFile));
            }

I hope you like it.

This question has already been answered. Start a new discussion instead.