本文整理汇总了C#中ICSharpCode.SharpZipLib.BZip2.BZip2InputStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# BZip2InputStream.Close方法的具体用法?C# BZip2InputStream.Close怎么用?C# BZip2InputStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.BZip2.BZip2InputStream
的用法示例。
在下文中一共展示了BZip2InputStream.Close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Extract
public void Extract(string path, string dest_dir)
{
BZip2InputStream bz2stream = new BZip2InputStream(new FileStream( path, FileMode.Open));
TarExtracter untar = new TarExtracter();
untar.Extract(bz2stream, dest_dir);
bz2stream.Close();
}
示例2: UnzipString
public static string UnzipString(string compbytes)
{
string result;
MemoryStream m_msBZip2 = null;
BZip2InputStream m_isBZip2 = null;
try
{
m_msBZip2 = new MemoryStream(Convert.FromBase64String(compbytes));
// read final uncompressed string size stored in first 4 bytes
//
using (BinaryReader reader = new BinaryReader(m_msBZip2, System.Text.Encoding.ASCII))
{
Int32 size = reader.ReadInt32();
m_isBZip2 = new BZip2InputStream(m_msBZip2);
byte[] bytesUncompressed = new byte[size];
m_isBZip2.Read(bytesUncompressed, 0, bytesUncompressed.Length);
m_isBZip2.Close();
m_msBZip2.Close();
result = Encoding.ASCII.GetString(bytesUncompressed);
reader.Close();
}
}
finally
{
if (m_isBZip2 != null)
{
m_isBZip2.Dispose();
}
if (m_msBZip2 != null)
{
m_msBZip2.Dispose();
}
}
return result;
}
示例3: OpenFile
private void OpenFile(object param)
{
IProgressFeedback progress = param as IProgressFeedback;
FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open);
BZip2InputStream stream = new BZip2InputStream(fs);
dataSet.ReadXml(stream);
stream.Close();
fs.Close();
dataSet.Tables[0].EndLoadData();
progress.ProgressUpdate("Opened", 100);
AnalyzePackets(progress);
progress.ProgressUpdate("Finishing", 100);
Invoke(new ThreadStart(RestoreDataSource));
progress.OperationComplete();
}
示例4: Decompress
public byte[] Decompress(byte[] data, UInt32 size)
{
byte[] result;
Stream inStream = new MemoryStream(data);
Stream outStream = new MemoryStream((int)size);
try {
using (BZip2InputStream bzipInput = new BZip2InputStream(inStream)) {
bzipInput.IsStreamOwner = false;
StreamUtils.Copy(bzipInput, outStream, new byte[4096]);
bzipInput.Close();
result = (outStream as MemoryStream).ToArray();
}
} catch (Exception e){
result = null;
} finally {
inStream.Close();
outStream.Close();
}
return result;
}
示例5: OpenFile
private void OpenFile(object param)
{
IProgressFeedback progress = param as IProgressFeedback;
Capture.DumpFile df = new Capture.DumpFile();
df.Load(openFileDialog.FileName, progress);
foreach (DumpEvent ev in df.Events.Values)
{
DataRow row = dataSet.Tables[0].NewRow();
row[eventCol] = ev;
row.AcceptChanges();
dataSet.Tables[0].Rows.Add(row);
}
dataSet.Tables[0].EndLoadData();
progress.ProgressUpdate("Opened", 100);
progress.ProgressUpdate("Finishing", 100);
Invoke(new ThreadStart(RestoreDataSource));
progress.OperationComplete();
#if false
IProgressFeedback progress = param as IProgressFeedback;
FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open);
BZip2InputStream stream = new BZip2InputStream(fs);
dataSet.ReadXml(stream);
stream.Close();
fs.Close();
dataSet.Tables[0].EndLoadData();
progress.ProgressUpdate("Opened", 100);
AnalyzePackets(progress);
progress.ProgressUpdate("Finishing", 100);
Invoke(new ThreadStart(RestoreDataSource));
progress.OperationComplete();
#endif
}
示例6: Main
static void Main(string[] args)
{
// Configuration section
string startFormat = "Directory Name";
string endFormat = "\"";
Console.WriteLine("Please specify a folder path that contains bz or xml filelist documents");
string filepath = Console.ReadLine();
// Create a new explorer process for selecting folder
Process explorerProcess = new Process();
// Get current user's username directory and starts
string userProfileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
// Using statement explicitly ensures that the instance is disposed of properly.
using (FolderBrowserDialog fileDialogue = new FolderBrowserDialog()) {
// Saves the dialogue in an DialogResult instance
DialogResult result = fileDialogue.ShowDialog();
// Saves selected directory, and files in directory
string fileDirectory = fileDialogue.SelectedPath.ToString();
string[] fileArray = Directory.GetFiles(fileDialogue.SelectedPath);
// TEMP, string of entire file
string files = string.Join(" ", fileArray);
foreach(string file in fileArray) {
// Stores the file in bzis
BZip2InputStream bzis = new BZip2InputStream(File.OpenRead(file));
// Create file at directory + txt
String fileName = fileDirectory + "\\temp.txt";
FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate);
bzis.CopyTo(fileStream);
String fileWrite = fileDirectory + "\\finalList.txt";
fileStream.Close();
using (StreamReader sr = File.OpenText(fileName)) {
String line;
while ((line = sr.ReadLine()) != null) {
Regex reg = new Regex("\\B(<Directory Name=)\\B\".*?\"");
MatchCollection matches = reg.Matches(line);
// Count to see whether the directory is a subchild
int i = 0;
using (StreamWriter swr = new StreamWriter(fileWrite, true)) {
foreach (var item in matches) {
swr.WriteLine(item.ToString());
}
}
}
}
// Close
bzis.Close();
// Creates a new byte buffer, and stores the contents of the bzip into the buffer
//byte[] byteBuffer = new byte[bzis.Length];
//bzis.Read(byteBuffer, 0, byteBuffer.Length);
// Close the stream as we dont need it.
//bzis.Close();
/*
// Encode into string before returning
string tempBZString = bString.ToString();
Regex reg = new Regex("\".*?\"");
MatchCollection matches = reg.Matches(tempBZString);
using (StreamWriter streamWriterFile = new StreamWriter(fileDirectory + "\\temp.txt")) {
foreach (var item in matches) {
streamWriterFile.WriteLine(item.ToString());
}
}
*/
}
}
// Prevents the console from closing automatically, by inserting breakpoint
Console.WriteLine("Press enter to close...");
Console.ReadLine();
}
示例7: DeCompress
public byte[] DeCompress(byte[] bytesToDecompress)
{
//Sets up the write data byte array (acts as a buffer array for the decompression, in 4096 byte blocks)
byte[] writeData = new byte[4096];
//Set up the initial Stream object (used a compact method by creating the memory stream form the byte-array and passing in all in one)
Stream s2 = new BZip2InputStream(new MemoryStream(bytesToDecompress));
//Stringbuilder which will hold the results of the decompression
MemoryStream outStream = new MemoryStream();
while(true)
{
//The business end, pops the next 4096 bytes from the Stream into the writeData buffer
int size = s2.Read(writeData,0,writeData.Length);
if(size>0)
{
outStream.Write(writeData,0,size);
}
else
{
break;
}
}
s2.Close();
byte[] outArr = outStream.ToArray();
outStream.Close();
return outArr;
}
示例8: UncompressBuffer
public byte[] UncompressBuffer(ref byte[] buffer)
{
MemoryStream Compressed = new MemoryStream(buffer);
MemoryStream UnCompressed = new MemoryStream();
try
{
BZip2InputStream zisUncompressed = new BZip2InputStream(Compressed);
int size;
byte[] data = new byte[4096];
do
{
size = zisUncompressed.Read(data, 0, data.Length);
UnCompressed.Write(data, 0, size);
}while (size > 0);
zisUncompressed.Close();
Compressed.Close();
byte []bUncompressedData = UnCompressed.GetBuffer();
UnCompressed.Close();
return bUncompressedData;
}
catch(Exception ex)
{
WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public byte[] UncompressBuffer(ref byte[] buffer)",ex,"",false);
}
return null;
}