.net - how to copy all files from a folder to another folder in c# -


please let me know how copy files within folder folder in c# .net.

currently using :

int j = 1; int k = 1;      (j = 1; j < 5; j++)     {          (k = 1; k < 32; k++)         {              string sourcepath = @desktop_location + "\test" + k + ".log";              if (system.io.file.exists(sourcepath))             {                 file.copy(@desktop_location + "\\statistics\\server" + j + "\test" + k + ".log", @desktop_location + "\\statistics\\transfer\\test" + j + k + ".log");                 //console.writeline("test result");             }             else             {                 //console.writeline("test"); 

string[] filepaths = directory.getfiles(@"c:\mydir\"); 

see getting files directory

string mypath = @"c:\test"; foreach (string file in filepaths) {     fileinfo info = new fileinfo(file);     if (!file.exists(info.fullname))     {        file.copy(info.fullname, newpath);     } } 

see using fileinfo class, don't require here contains lot of useful functionality working files , folders. reading planning application.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -