Recurity.Swf.SwfFile.Write C# (CSharp) Method

Write() public method

Writes the contents of this SwfFile instance to a stream. Compression is used if configured.
public Write ( Stream output ) : void
output Stream The destination stream to write to
return void
        public void Write(Stream output)
        {
            if (SwfFile.Configuration.WriteCompressed)
            {
                CwsFile cws = new CwsFile();
                cws.CompressionLevel = SwfFile.Configuration.WriteCompressionLevel;
                cws.WriteContent = new MemoryStream();
                WriteContent(cws.WriteContent);
                cws.Version = this.Version;
                // copy frame information from old FWS record
                cws.FrameHeader = FwsSource.FrameHeader;
                cws.Write(output);
            }
            else
            {
                FwsFile fws = new FwsFile();
                fws.WriteContent = new MemoryStream();
                WriteContent(fws.WriteContent);
                fws.Version = this.Version;
                // copy frame information from old FWS record
                fws.FrameHeader = FwsSource.FrameHeader;
                fws.Write(output);
            }
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Scans a single file
        /// </summary>
        /// <param name="s1">The input file name</param>
        /// <param name="s2">The output file name</param>
        private static void ScanSingle(string s1, string s2)
        {
            bool read = false;
            bool verified = false;

            try
            {
                FileInfo f = new FileInfo(s2);

                if (!Directory.Exists(f.DirectoryName))
                {
                    Directory.CreateDirectory(f.DirectoryName);
                }
            }
            catch (Exception e)
            {
                throw new DirectoryNotFoundException(e.Message);
            }

            SwfFile file = new SwfFile();

            try
            {
                using (FileStream fs = File.OpenRead(s1))
                {
                    Console.WriteLine(" Reading: " + s1);
                    file.Read(fs);
                    Console.WriteLine(" Reading successfull");
                    read = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(" Read error : " + e.Message + Environment.NewLine);
            }

            if (read)
            {
                Console.WriteLine(" Verifiying: " + s1);

                try
                {
                    file.Verify();
                    Console.WriteLine(" Verifiying successfull");
                    verified = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine(" Verifiy error : " + e.Message + Environment.NewLine);

                }
            }

            if (read && verified)
            {
                Console.WriteLine(" Writing: " + s2);

                try
                {
                    using (FileStream fs = File.OpenWrite(s2))
                    {
                        file.Write(fs);
                        Console.WriteLine(" Writing successfull" + Environment.NewLine);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(" Write error : " + e.Message + Environment.NewLine);
                }
            }
        }
All Usage Examples Of Recurity.Swf.SwfFile::Write