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

Iftikar HussainRank #423 · 5.9K reputationPosted Aug 11, 2013, 6:49 AM EDT
In normal code you can't use order by and group by option. It will be better if you can explain what exactly you need inside the for loop
Regards,
Iftikar
R Ravula20 reputationPosted Aug 11, 2013, 7:43 AM EDT
I am trying to zip files in C# for last 6 months and here is the code, but I don't want to use LINQ because I have to run it in Visual Studio 2003 which does not support LINQ.
Regards,
R
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 11, 2013, 7:51 AM EDT
Regards,
Iftikar
VulpesRank #55 · 29.2K reputationPosted Aug 11, 2013, 1:16 PM EDT
You'll therefore need to use the ArrayList and Hashtable classes rather than their generic equivalents.
Although it's difficult to be sure as I no longer have VS 2003, the following should work but won't necessarily return the groups of files (by month) in the same order as the LINQ code did:
R Ravula20 reputationPosted Aug 14, 2013, 7:10 AM EDT
Ionic.Zip dll is not working with .NET 1.1. Please advise!
Thanks,
R
VulpesRank #55 · 29.2K reputationPosted Aug 14, 2013, 9:16 AM EDT
However, I do remember that the runtime library of the now defunct .NET language J# (Java compatible) contained lots of stuff that the .NET framework 1.1 lacked including zip/unzip support.
I've dug out a couple of old articles which show how to use this from C# and I'd check them out to see whether you can use it instead of Ionic.Zip:
http://www.codeproject.com/Articles/6850/Zip-and-Unzip-from-a-C-program-using-J-runtime
http://msdn.microsoft.com/en-us/magazine/cc164129.aspx