public static void Main111() { var files = Directory.EnumerateFiles(@"d:\", "*.gz*", SearchOption.TopDirectoryOnly); foreach (var file in files) { var r = false; string path = string.Empty; try { if ( ZipFileHelper .Decompress ( file , @"d:\temp" , (x) => { var s = ".Gz"; int p = x.ToLower().LastIndexOf(s.ToLower()); if (p > 0) { x = x.Remove(p + 1, s.Length); } return(x); } , out path ) ) { r = PathFileHelper .MoveFileTo ( path , @"d:\Temp" , @"d:\Temp2" , true ); } } catch (Exception e) { string log = string .Format ( "Process file: [{1}] caught exception:{0}{2}" , "\r\n" , file , e.ToString() ); Console.Error.WriteLine(log); //EventLogHelper // .WriteEventLogEntry // ( // "" // , 1001 // , log // , 101 // , EventLogEntryType.Error // ); r = false; } if (r) { PathFileHelper .MoveFileTo ( file , @"d:\" , @"d:\Temp3" , true ); Console.WriteLine("ok: {0}", file); } else { PathFileHelper .MoveFileTo ( file , @"d:\Temp" , @"d:\Temp4" , true ); } } Console.ReadLine(); }