using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace imagecoppy { class Program { static void Main(string[] args) { formatDri(); Console.ReadKey(); } static void renameFiles() { } static void formatDri() { System.IO.DirectoryInfo dif = new System.IO.DirectoryInfo(@"D:\vishwa"); System.IO.DirectoryInfo[] subdif = dif.GetDirectories(); System.IO.DirectoryInfo txtdir = dif.CreateSubdirectory("TEXTFILES"); System.IO.FileInfo[] dirname; foreach (System.IO.DirectoryInfo sub in subdif) { dirname = sub.GetFiles("*.txt*"); if (dirname.Length != 0) { txtdir.CreateSubdirectory(sub.Name); foreach (System.IO.FileInfo txtfile in dirname) { txtfile.CopyTo(@"D:\vishwa\TEXTFILES\" + sub.Name + "\\" + txtfile.Name, false); } } System.IO.FileInfo[] txtInfo=dif.GetFiles("*.txt*"); // this part is same as the previous post } } } }
Sunday, May 5, 2013
Arrange text files in a directory according to their previous folder names (C#)
This is a program that can re arrange all the text files in a directory in another directory within folders which having their previous folder names. You can try this for any file type (I did for text files).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment