1
Answer

How to delete files?

softairhk

softairhk

21y
1.6k
1
Hello! I would like to know how to delete files? I know the following coding can do copy directory and files, so how to modify it to delete files. public static void copyDirectory(string Src,string Dst) { String[] Files; if(Dst[Dst.Length-1]!=Path.DirectorySeparatorChar) Dst+=Path.DirectorySeparatorChar; if(!Directory.Exists(Dst)) Directory.CreateDirectory(Dst); Files=Directory.GetFileSystemEntries(Src); foreach(string Element in Files) { // Sub directories if(Directory.Exists(Element)) copyDirectory(Element,Dst+Path.GetFileName(Element)); // Files in directory else File.Copy(Element,Dst+Path.GetFileName(Element),true); } }
Answers (1)