【发布时间】:2014-01-03 07:33:24
【问题描述】:
我尝试使用此代码:
public void Extract(string SourceFile, string password)
{
SevenZipExtractor szip = new SevenZipExtractor(SourceFile, password);
foreach (DataGridViewRow row in DGVFile.Rows)
{
string NameFile = (string)row.Cells[0].Value;
int indexZip = szip.ArchiveFileData.IndexOf(NameFile);
Stream pathDirectory = @"C:\\";
szip.ExtractFile(indexZip, pathDirectory);
}
}
但那是错误,在第 7 行和第 8 行。也许任何人都可以解释如何使用在我的 datagridview 中选择的名称以及变量 pathDirectory 中文件流的用途来获取我的存档中的索引文件。 谢谢
编辑: 我使用 DataGridView DGVDekripsi,所以我替换了它。这个正确的代码,它可以工作。
public void Extract(string SourceFile, string password)
{
string OutputLocation = txtOutputDe.Text;
SevenZipExtractor szip = new SevenZipExtractor(SourceFile, password);
foreach (DataGridViewRow row in DGVDekripsi.Rows)
{
string NameFile = (string)row.Cells[1].Value;
FileStream fs = File.OpenWrite(Path.Combine(OutputLocation, NameFile));
szip.ExtractFile(NameFile, fs );
}
return;
}
【问题讨论】:
-
究竟是什么错误?
-
第 7 行:无法从 'System.Windows.Forms.DataGridViewTextBoxColumn' 转换为 'SevenZip.ArchiveFileInfo'
-
第 8 行:无法将类型“字符串”隐式转换为“System.IO.Stream”
标签: c# stream extract sevenzipsharp