Im trying to use MoveTo and a generic way to rename the files. but i need a way of iterating through the list, i had somthing the other night and it got lost but it was somthing like this
DirectoryInfo di = new DirectoryInfo("FILE PATH");
foreach (FileInfo fi in di.FileInfo)
{
do stuff
}
but i know that doesnt work, does anyone have a way of getting the list of files, then iterating though that list

Working With DirectoryInfo to Move Files
ssfftt
You need something like this:
string[] arrFilesInDirectory = Directory.GetFiles(@"D:\\RizwanSharp");
for (int i = 0; i < arrFilesInDirectory.Length; i++)
{
File.Move(arrFilesInDirectory, /*Put your new name here*/ );
}
There is not Rename method, If you use Move for the same direcory then file will be renamed if you use Move and specify destination file path to be some other directory then it'll be a move.
This is only an example, You can See Overloads of GetFiles to get files only of specific extenction or go in sub directories or not.
Even you can do string processing on each file's name before moving it.
This is fairly simple and I kept is as simple as I could to explain you. So I let the rest for you to experiment.
If you face any problem, feel free to ask again.
Best Regards and Best of Luck.
Rizwan aka RizwanSharp;
Nakkeeran R
Following may help you
Hope this helps you.
UnknownScripter
heres what i got
private
void button1_Click(object sender, EventArgs e){
DirectoryInfo DI = new DirectoryInfo("C:\\Roms"); StreamWriter sw = new StreamWriter("C:\\txt.txt"); foreach (FileInfo file in DI.GetFiles()){
int i = file.Name.IndexOf(")"); string temp = file.Name.Substring(0,i - 2); if (file.Name.IndexOf("(U)") != -1){
Directory.CreateDirectory("C:\\Roms\\United States\\" + temp); try { file.MoveTo("C:\\Roms\\United States\\" + temp + "\\" + file.Name); } catch (IOException exception){
}
}
else if (file.Name.IndexOf("(E)") != -1){
Directory.CreateDirectory("C:\\Roms\\Europe\\" + temp); try { file.MoveTo("C:\\Roms\\Europe\\" + temp + "\\" + file.Name); } catch (IOException exception){
}
}
else if (file.Name.IndexOf("(J)") != -1){
Directory.CreateDirectory("C:\\Roms\\Japanese\\" + temp); try { file.MoveTo("C:\\Roms\\Japanese\\" + temp + "\\" + file.Name); } catch (IOException exception){
}
}
else{
Directory.CreateDirectory("C:\\Roms\\Others\\" + temp); try { file.MoveTo("C:\\Roms\\Others\\" + temp + "\\" + file.Name); } catch (IOException exception){
}
}
}
sw.Close();
}