R Ravula

R Ravula

  • NA
  • 20
  • 9.8k

Convert LINQ C# to normal C# code

Aug 11 2013 10:08 AM
Hi,

Can you please help me converting below two LINQ queries (Inside foreach loops) to normal/regular C# code:

DirectoryInfo di = new DirectoryInfo(path);
            try
            {
                
                DirectoryInfo[] subdirs = di.GetDirectories();
                foreach (DirectoryInfo dinfo in subdirs)
                {
                    var files = dinfo.GetFiles("*").Where(w=>(w.LastWriteTime<=DateTime.Now.AddMonths(-6))).OrderByDescending(s => s.LastWriteTime).GroupBy(e => e.LastWriteTime.Month).ToList();
                   
                    foreach (var item in files)   
                    {
                        SaveZip(item.Select(s=>s).ToList());
                    }
                }

Thanks,
R

Answers (6)