string[] format = {"*.jpg","*.doc","*.exe","*.pdf","*.xls" }; # File stream Operations Delete, copy, transfer multiple files/// <summary> ///Delete all pictures under folder/// </summary> /// <param name= "Oldpngpath" >file path to delete</param> /// <param name= "Newpngpath" >new directory to delete</param> /// <param name= "GeSHi" >the format of the action file for example: *.png, *.xml</param> Public voidDeleteAll (stringDelpath,stringformat) { string[] files = Directory.GetFiles (Delpath, format[0]); foreach(stringFileinchfiles) {File.delete (File); } } /// <summary> ///Copy all pictures under folder/// </summary> /// <param name= "Oldpngpath" >file path to be copied</param> /// <param name= "Newpngpath" >new directory to which to copy</param> /// <param name= "GeSHi" >the format of the action file for example: *.png, *.xml</param> Public voidCopyall (stringOldpngpath,stringNewpngpath,stringformat) { string[] files = Directory.GetFiles (Oldpngpath, format[0]); foreach(stringFileinchfiles) { stringOtherfile =Path.Combine (Oldpngpath, Path.getfilename (file)); File.Copy (file, Newpngpath+"\\"+path.getfilename (file)); } } /// <summary> ///move all files under a folder/// </summary> /// <param name= "Olderpath" >file directory to be moved</param> /// <param name= "Topath" >New Catalog</param> Public voidMoveall (stringOlderpath,stringTopath) { string[] files = Directory.GetFiles (Delpath, format[0]); foreach(stringFileinchfiles) {File.move (File, topath);//Moving Files } }
C # File Operations Delete, copy, transfer multiple files [go]