C# Copy file or folder -
i trying write program keep multiple folders in sync. this, need copy , delete files , subfolders.
to me, doesn't make difference if object file or folder, want create necessary parent folders , copy object, overwriting if necessary. i'm using jagged array of filesysteminfo hold files/folders.
this has advantage of avoiding duplication of code sync files , folders separately.
however, can't figure out how copy filesysteminfo. i'm looking way able copy/delete/read creation or modified time work on both files , folders.
filesysteminfo don't have copy or delete methods base class directoryinfo , fileinfo.
so when loop on filesysteminfo objects have cast proper concrete class , use specific copy/delete methods.
foreach( var fsi in filesysteminfoobjects ) { if( fsi directoryinfo ) { var directory = (directoryinfo)fsi; //do } else if (fsi fileinfo ) { var file = (fileinfo)fsi; //do } }
Comments
Post a Comment