我正在尝试从字节数组创建一个新的 FileStream 对象。我确信这根本没有意义,所以我将在下面尝试更详细地解释。
我正在完成的任务:
1)读取之前的源文件压缩的2)使用GZipStream解压数据
3)将解压后的数据复制到字节数组中。
我想改变的是:
1)我希望能够使用 File.ReadAllBytes 读取解压后的数据。
2)然后我想使用这个字节数组创建一个新的文件流对象。
简而言之,我想使用字节数组来完成整个操作。 GZipStream 的参数之一是某种流,所以我认为我被困在使用文件流。但是,如果存在某种方法,我可以从字节数组创建 FileStream 的新实例 - 那么我应该没问题。
这是我到目前为止所拥有的:
FolderBrowserDialog fbd = new FolderBrowserDialog(); // Shows a browser dialog
fbd.ShowDialog();
// Path to directory of files to compress and decompress.
string dirpath = fbd.SelectedPath;
DirectoryInfo di = new DirectoryInfo(dirpath);
foreach (FileInfo fi in di.GetFiles())
{
zip.Program.Decompress(fi);
}
// Get the stream of the source file.
using (FileStream inFile = fi.OpenRead())
{
//Create the decompressed file.
string outfile = @"C:\Decompressed.exe";
{
using (GZipStream Decompress = new GZipStream(inFile,
CompressionMode.Decompress))
{
byte[] b = new byte[blen.Length];
Decompress.Read(b,0,b.Length);
File.WriteAllBytes(outfile, b);
}
}
}
谢谢你的帮助!
问候,
埃文
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)