LSLib.LS.PackageReader.Dispose C# (CSharp) Méthode

Dispose() public méthode

public Dispose ( ) : void
Résultat void
        public void Dispose()
        {
            foreach (var stream in streams)
            {
                stream.Dispose();
            }
        }

Usage Example

Exemple #1
0
        public void UncompressPackage(string packagePath, string outputPath)
        {
            if (outputPath.Length > 0 && !outputPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                outputPath += Path.DirectorySeparatorChar;
            }

            ProgressUpdate("Reading package headers ...", 0, 1, null);
            var     reader  = new PackageReader(packagePath);
            Package package = reader.Read();

            long totalSize   = package.Files.Sum(p => (long)p.Size());
            long currentSize = 0;

            var buffer = new byte[32768];

            foreach (AbstractFileInfo file in package.Files)
            {
                ProgressUpdate(file.Name, currentSize, totalSize, file);
                currentSize += file.Size();

                string outPath = outputPath + file.Name;

                FileManager.TryToCreateDirectory(outPath);

                Stream inStream = file.MakeStream();

                try
                {
                    using (var inReader = new BinaryReader(inStream))
                    {
                        using (var outFile = File.Open(outPath, FileMode.Create, FileAccess.Write))
                        {
                            int read;
                            while ((read = inReader.Read(buffer, 0, buffer.Length)) > 0)
                            {
                                outFile.Write(buffer, 0, read);
                            }
                        }
                    }
                }
                finally
                {
                    file.ReleaseStream();
                }
            }

            reader.Dispose();
        }
All Usage Examples Of LSLib.LS.PackageReader::Dispose