提取CSV压缩文件 [英] extract csv zip file
本文介绍了提取CSV压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
尝试解压缩zip文件时出现问题.
我的代码如下.
Hello,
I have a problem when trying to extract the zip file.
my code is below.
FileStream writeStream = new FileStream("test.csv.zip", FileMode.Create);
int Length = 2048;
int i = (int)fileSize / 2048 + 1;
int j = 0;
Byte[] buffer = new Byte[Length];
int bytesRead = responseStream.Read(buffer, 0, Length);
while (bytesRead > 0)
{
writeStream.Write(buffer, 0, bytesRead);
bytesRead = responseStream.Read(buffer, 0, Length);
}
writeStream.Close();
response.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
param par = p;
string url = string.Empty;
string TimeLeft = string.Empty;
string writeLine = string.Empty;
DateTime date = DateTime.Now.AddDays(par.days);
string find = date.Month.ToString() + "/" + date.Day.ToString() + "/" + date.Year.ToString();
using (Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read("test.csv.zip"))
{
zip.ExtractAll("temp", Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
}
Error:- bad read of entry test.csv from compressed archive.
虽然zip文件中有数据,但是如果我手动提取数据,则会得到数据,但是使用此代码,我会报错.
您能告诉我我在哪里犯错或解决方法吗?
谢谢和问候!
Kuldeep Dwivedi
Although zip file have data If I extract manually I get the data but with this code I am getting error .
Can you please tell me where I did mistake or the solution.
Thanks and Regards!
Kuldeep Dwivedi
推荐答案
由于问题的根源尚不清楚,请尝试首先确定该问题:
- 是zip文件吗?
- 是您的wget代码吗?
- 是文件系统缓存(存储为文件并立即再次读取可能是文件系统缓存问题)吗? )?
- 是您的解压缩呼叫吗?
- ...?
Since the source of the problem is unclear, try to identify that first:
- is it the zip file?
- is it your wget code?
- is it the file system caching (stored as file and immediately read again may fall into file system caching problems)?
- is it your unzip call?
- ...?
- 将zip文件存储到文件系统中,并通过文件资源管理器ZIP.exe,RAR,exe,7z.exe或任何其他解压缩程序将其提取
- 如果成功1.如果没有成功,则解压缩调用似乎有问题
- 尝试通过其他方式(不在您自己的情况下)获取文件,或者该文件已损坏或您的手工wget损坏了.程序(wget,ftp,...)并将其解压缩到外部(请参阅2.)
- store the zip file to the file system and extract it by the file explorer, ZIP.exe, RAR,exe, 7z.exe, or any other unzipper
- if 1. was successful, the ionic unzipper call seems to be problematic
- if 1. was unsuccessful, either the file is corrupt or your hand crafted wget is broken
- try to acquire the file by other means, outside of your program (wget, ftp, ...) and unzip it with outside as well (see 2.)
顺便说一句:您只提供一半的代码.没有机会检查您的wget代码可能有什么问题.
BTW: you provide only half of the code. No chance to check what might be wrong with your wget code.
这篇关于提取CSV压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文