C# FileInfo Name foreach -


i have code:

fileinfo finfo = new fileinfo(path.combine(directory.getcurrentdirectory(), "cleo", file.key));  dialogresult modifiedcleofiles = messagebox.show("error", "error title", messageboxbuttons.okcancel, messageboxicon.warning);  if(modifiedcleofiles == dialogresult.ok) {     message.info(finfo.name); //it prints filename ok     if (!directory.exists(path.combine(directory.getcurrentdirectory(), "gs", "cleo")))          directory.createdirectory(path.combine(directory.getcurrentdirectory(), "gs", "cleo"));      foreach (fileinfo filemove in finfo) //i don't know how make foreach     {         filemove.moveto(path.combine(directory.getcurrentdirectory(), "gs", "cleo", filemove.name));     } } 

so it's problem. code works fine without foreach, works with:

finfo.moveto(path.combine(directory.getcurrentdirectory(), "gs", "cleo", finfo.name)); 

it's ok, if there more 2 files, etc.. shows 2 messageboxes.. wan't move finfo files. note finfo files, not files exists in folder ! in advance :( p.s not give -karma or etc, i'm newbie..

p.s i'm tried code:

foreach (fileinfo filemove in finfo.directory.enumeratefiles()) {     filemove.moveto(path.combine(directory.getcurrentdirectory(), "gs", "cleo", filemove.name)); } 

it move's files folder, need finfo..

just add

.where(i => i.extension.equals(".finfo", stringcomparison.invariantcultureignorecase)) 

to enumerable. or better, use other overload of enumeratefiles:

foreach (fileinfo filemove in finfo.directory.enumeratefiles("*.finfo")) { 

also, note moveto works on same logical drive. if that's not enough you, need add own copy+delete method moving files accross drives.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -