I’ve wanted to rename a lots of files. I’ve also wanted the name of the files to follow my convention to capitalize every first letter. I couldn’t find such functionality in the string class. I’ve googled and I’ve found the TextInfo class and ToTitleCase method. It gets the job done and perfectly suits me needs.
Here’s how we can use it
TextInfo ti = Thread.CurrentThread.CurrentCulture.TextInfo; string name = "petar petrov - XML developer"; string properName = ti.ToTitleCase(name); // properName = "Petar Petrov - XML Developer"
Note that the XML isn’t transformed to Xml which is the correct behavior for me.