Well, the way I would do it is that I would get all the files in the
directory using the GetFiles method on the DirectoryInfo instance which
represents the directory. At this point, you can sort the files according
to your criteria (if not, use the GetFiles method on the Directory class,
since it should be faster, since it only returns names of the files, and not
file info classes).
Once you have that, you can cycle through the array, and call the static
Move method on the File class to rename the file.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mvp@spam.guard.caspershouse.com
<null@null.com> wrote in message
news:em4i0TVDGHA.336@TK2MSFTNGP14.phx.gbl...[color=blue]
>I am a novice in C# and need help. I want to write a simple program to
>read a bunch of files from a specified directory and rename those files in
>a sequential fashion., changing a bunch of image file names.
>
> For example, changing:
> a011.jpg
> a 011.1.jpg
> i234.jpg
>
> to
>
> img001.jpg
> img002.jpg
> img003.jpg
>
> There are some 600 files, so doing it manually would be a pain. I don't
> know my C# or .NET framwork well enough yet to do this by myself quickly.
> I think I should be able to do it with a simple console program. I am
> hoping somebody could help me.
>
>
>[/color]