protected override void OnLoad(EventArgs e) { base.OnLoad(e); string on = @"C:\PathOldFolder"; string nn = @"C:\PathNewFolder"; Directory.CreateDirectory(nn); this.ChangeFileNamesToTitleCase(new DirectoryInfo(on), new DirectoryInfo(nn)); } public void ChangeFileNamesToTitleCase(DirectoryInfo o, DirectoryInfo n) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; foreach (FileInfo f in o.GetFiles()) { string nfn = f.FullName.Replace(o.FullName, n.FullName); nfn= nfn.Replace(f.Name, textInfo.ToTitleCase(f.Name)); File.Copy(f.FullName, nfn); } foreach (DirectoryInfo c in o.GetDirectories()) { string ndn = c.FullName.Replace(o.FullName, n.FullName); ndn = ndn.Replace(c.Name, textInfo.ToTitleCase(c.Name)); Directory.CreateDirectory(ndn); this.ChangeFileNamesToTitleCase(c, new DirectoryInfo(ndn)); } }
Saturday, July 31, 2010
How to rename all the files in a directory using c# (Convert to title case)
Subscribe to:
Post Comments (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...
No comments:
Post a Comment