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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -