當前位置: 首頁>>代碼示例>>C#>>正文


C# Stream.Close方法代碼示例

本文整理匯總了C#中System.Stream.Close方法的典型用法代碼示例。如果您正苦於以下問題:C# Stream.Close方法的具體用法?C# Stream.Close怎麽用?C# Stream.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Stream的用法示例。


在下文中一共展示了Stream.Close方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Convert

 public static void Convert(String htmlFilename, String mhtFilename)
 {
     var objMessage = new Message();
     objMessage.CreateMHTMLBody(htmlFilename);
     var strm = new Stream {Type = StreamTypeEnum.adTypeText, Charset = "US-ASCII"};
     strm.Open();
     IDataSource dsk = objMessage.DataSource;
     dsk.SaveToObject(strm, "_Stream");
     strm.SaveToFile(mhtFilename, SaveOptionsEnum.adSaveCreateOverWrite);
     strm.Close();
 }
開發者ID:r0llup,項目名稱:ProjectReport,代碼行數:11,代碼來源:MhtConverter.cs

示例2: AddStream

        /// <summary>
        /// Add full contents of a stream into the Zip storage
        /// </summary>
        /// <param name="_method">Compression method</param>
        /// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
        /// <param name="_source">Stream object containing the data to store in Zip</param>
        /// <param name="_modTime">Modification time of the data to store</param>
        /// <param name="_comment">Comment for stored file</param>
        public void AddStream(Compression _method, string _filenameInZip, Stream _source, DateTime _modTime, string _comment)
        {
            if (Access == FileAccess.Read)
                 throw new InvalidOperationException("Writing is not alowed");

             long offset;
             if (this.Files.Count == 0)
                 offset = 0;
             else
             {
                 ZipFileEntry last = this.Files[this.Files.Count - 1];
                 offset = last.HeaderOffset + last.HeaderSize;
             }

             // Prepare the fileinfo
             ZipFileEntry zfe = new ZipFileEntry();
             zfe.Method = _method;
             zfe.EncodeUTF8 = this.EncodeUTF8;
             zfe.FilenameInZip = NormalizedFilename(_filenameInZip);
             zfe.Comment = (_comment == null ? "" : _comment);

             // Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc.
             zfe.Crc32 = 0;  // to be updated later
             zfe.HeaderOffset = (uint)this.ZipFileStream.Position;  // offset within file of the start of this local record
             zfe.ModifyTime = _modTime;

             // Write local header
             WriteLocalHeader(ref zfe);
             zfe.FileOffset = (uint)this.ZipFileStream.Position;

             // Write file to zip (store)
             Store(ref zfe, _source);
             _source.Close();

             this.UpdateCrcAndSizes(ref zfe);

             Files.Add(zfe);
        }
開發者ID:aswartzbaugh,項目名稱:biketour,代碼行數:46,代碼來源:ZipStorer.cs

示例3: CopyToMemoryStream

        private static Stream CopyToMemoryStream(Stream s) {
            var size = 100000; // large heap is more efficient
            var copyBuff = new byte[size];
            int len;
            var r = new MemoryStream();
            while((len = s.Read(copyBuff, 0, size)) > 0)
                r.Write(copyBuff, 0, len);

            r.Seek(0, SeekOrigin.Begin);
            s.Close();
            return r;
        }
開發者ID:roomaroo,項目名稱:coapp.powershell,代碼行數:12,代碼來源:SgmlParseException.cs


注:本文中的System.Stream.Close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。