Windowsでファイルを解凍すると、私は時折、オリジナルOSにWindows用は長すぎる(大丈夫パス長すぎるパスでZIPファイルを解凍処理するためにどのように/
- に問題があるでしょう複製ファイルを作成しました)。これらの問題のうちの1つでzipファイルを読み込むたびに起因DotNetZipを使用した場合、鈍感
に「複製」されている
ZipFile.Read(path)
コールはがらくたます。つまり、私はそれをフィルタリングしようとすることはできません。 using (ZipFile zip = ZipFile.Read(path))
{
...
}
これらのファイルを読み取るには、どのような方法が最適ですか。
更新日:
例のzip、ここから: https://github.com/MonoReports/MonoReports/zipball/master
重複: https://github.com/MonoReports/MonoReports/tree/master/src/MonoReports.Model/DataSourceType.cs https://github.com/MonoReports/MonoReports/tree/master/src/MonoReports.Model/ DatasourceType.cs
例外の詳細は次のとおりです。
Ionic.Zip.ZipException:ZipFileとして読み取ることができません
---> System.ArgumentException:同じキーを持つ項目が既に追加されています。 System.ThrowHelper.ThrowArgumentException(ExceptionResourceリソース)System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
2.Add(処理鍵キー、TValue値)で
at System.Collections.Generic.Dictionary
Ionic.Zip.ZipFile.ReadCentralDirectory(ZIPファイルZF)で
ATで
Ionic.Zip.ZipFile.ReadIntoInstance(ZIPファイルZF)
解像度:
Cheesoの提案@に基づいて、私は、ストリームからの重複を避け、それらをすべてを読むことができる、とパスの問題:
//using (ZipFile zip = ZipFile.Read(path))
using (ZipInputStream stream = new ZipInputStream(path))
{
ZipEntry e;
while((e = stream.GetNextEntry()) != null)
//foreach(ZipEntry e in zip)
{
if (e.FileName.ToLower().EndsWith(".cs") ||
e.FileName.ToLower().EndsWith(".xaml"))
{
//var ms = new MemoryStream();
//e.Extract(ms);
var sr = new StreamReader(stream);
{
//ms.Position = 0;
CodeFiles.Add(new CodeFile() { Content = sr.ReadToEnd(), FileName = e.FileName });
}
}
}
}
ファイルは.zipまたは.gzですか? – SimpleVar
.zip(特にgithubファイルからダウンロード) – gameweld
エラーを表示できますか?ファイル内のパス名ですか?ターゲットファイルの場所が長すぎますか? – yamen