public static StreamReader OpenTextStripComments(this FileInfo fileInfo, bool allowGzip = true) { if (fileInfo == null) { throw new ArgumentNullException("fileInfo"); } if (allowGzip && ( fileInfo.Extension.Equals(".gz", StringComparison.CurrentCultureIgnoreCase) || fileInfo.Extension.Equals(".gzip", StringComparison.CurrentCultureIgnoreCase))) { #if SILVERLIGHT throw new Exception("Compressed files are not supported in Silverlight."); #else FileStream infile = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read); GZipStream zipStream = new GZipStream(infile, CompressionMode.Decompress); StreamReader reader = zipStream.StripComments(); return(reader); #endif } else { return(new CommentedStreamReader(fileInfo)); } }