Rename Files

Worf

Member
Joined
Dec 19, 2008
Messages
15
Hi.

How do you rename files to a number a charaters?

If i had a file called Purple flower.jpg and i wanted to rename it to purplef.jpg. How do i rename it to purplef.jpg


Many Thanks

Worf
 
Code:
String shortFileName = longFileName.Replace( ,).Substring(0,7) + "." + System.IO.File.GetExtention(longFileName);

You may want to check the return of GetExtention() it may include the period. But thats the idea. Assuming you want a fixed length; otherwise you could just use
Code:
.Replace("lower",String.Empty);
 
Back
Top