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
VulpesPosted Aug 14, 2013, 1:16 PM
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
R RavulaPosted Aug 14, 2013, 11:10 AM
Ionic.Zip dll is not working with .NET 1.1. Please advise!
Thanks,
R
VulpesPosted Aug 11, 2013, 5:16 PM
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:
Iftikar HussainPosted Aug 11, 2013, 11:51 AM
Regards,
Iftikar
R RavulaPosted Aug 11, 2013, 11:43 AM
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 HussainPosted Aug 11, 2013, 10:49 AM
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