c# - My Copy Directory Functions Fails Occasionally -
i'm having problems code below failing complete due not releasing file copying. wrap function in using statement, not sure how or if there better solution this.
thanks.
public static void copydirectory (string source, string destination) { if (!directory.exists (destination)) directory.createdirectory (destination); string [] sysentries = directory.getfilesystementries (source); foreach (string sysentry in sysentries) { string filename = path.getfilename (sysentry); string targetpath = path.combine (destination, filename); if (directory.exists (sysentry)) copydirectory (sysentry, targetpath); else file.copy (sysentry, targetpath, true); } // foreach (string sysentry in sysentries) }
Comments
Post a Comment