string sourceFilePath = @"E:\文件拷贝\xx\3773\3773.zip"; FileInfo fileInfo = new FileInfo(sourceFilePath);
long length = fileInfo.Length; if (length == )
{
return;
} using (ZipInputStream zip = new ZipInputStream(File.OpenRead(sourceFilePath)))
{
ZipEntry theEntry;
string destinationDirPath = @"\\172.21.3.21\liung\";
while ((theEntry = zip.GetNextEntry()) != null)
{
destinationDirPath += theEntry.Name; using (FileStream streamWriter = new FileStream(destinationDirPath, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Write))
{
byte[] bytes = new byte[zip.Length];
zip.Read(bytes, , bytes.Length);
streamWriter.Write(bytes, , bytes.Length);
} XmlTextReader xmlReader = new XmlTextReader(zip);
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name.ToLower() == "fileheader")
{
string reportTime = xmlReader.GetAttribute("reportTime").Replace("24:00:00", "23:59:59");
string startTime = xmlReader.GetAttribute("startTime").Replace("24:00:00", "23:59:59");
string endTime = xmlReader.GetAttribute("endTime").Replace("24:00:00", "23:59:59"); break;
}
}
}
} Console.ReadKey(); using (GZipInputStream zip = new GZipInputStream(File.OpenRead(sourceFilePath)))
{
using (XmlTextReader xmlReader = new XmlTextReader(zip))
{
while (xmlReader.Read())
{
// hw没有period,暂时给一个默认值15
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name.ToLower() == "fileheader")
{
string reportTime = xmlReader.GetAttribute("reportTime").Replace("24:00:00", "23:59:59");
string startTime = xmlReader.GetAttribute("startTime").Replace("24:00:00", "23:59:59");
string endTime = xmlReader.GetAttribute("endTime").Replace("24:00:00", "23:59:59"); break;
}
}
}
}