I dont know whats my mistake.
FileInfo[] FileInformation = DirectoryInfo.GetFiles(textBoxPath.Text);
for (int i = 0; i <= FileInformation.Length; i++)
{
Use the following:
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(textBoxPath.Text);
System.IO.FileInfo[] fileInformations = dir.GetFiles();
for (int i = 0; i <= fileInformations.Length; i++)
{
System.IO.File.Move(fileInformations[i].DirectoryName, System.IO.Path.Combine(FileInformation[i].Directory, "File" + i));
}
EDIT:
renamed your FileInformation
to the properway to write local variable names fileInformations
. Used Path.Combine
to combine paths and filename instead of using string combination, as this will take care of missing / and other path issues.