C# FileInfo move foreach -


i have code:

fileinfo finfo = new fileinfo(path.combine(directory.getcurrentdirectory(), "backup", file.key));  var fsize = finfo.length;  if (fsize != file.value) {     dialogresult modifiedcleofiles = messagebox.show("oops! modified files found! click ok move them!", "error", messageboxbuttons.okcancel, messageboxicon.warning);      if(modifiedcleofiles == dialogresult.ok)     {         foreach (fileinfo filemove in finfo)         {             finfo.moveto(path.combine(directory.getcurrentdirectory(), "backup", filemove.name));         }      }      return; } 

but it's error foreach, how can fix it?

p.s i'm error:

foreach statement not work variables of type system.io.fileinfo

if iterate multiple items in directory, need directoryinfo, not fileinfo, object.

assuming want files in finfo's directory, code should this:

foreach (fileinfo filemove in finfo.directory.enumeratefiles()) {     ... } 

finfo.directory gives directoryinfo finfo's directory, , enumeratefiles() lets go on content in foreach loop.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -