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

node.js - StackOverflow API not returning JSON -

python - Subclassed QStyledItemDelegate ignores Stylesheet -

sql server - TFS 2012 TF255062 Error after removing 'Active Directory' Role -