当前位置: 首页>>代码示例>>C#>>正文


C# Attachment.GetStreamBytes方法代码示例

本文整理汇总了C#中Attachment.GetStreamBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Attachment.GetStreamBytes方法的具体用法?C# Attachment.GetStreamBytes怎么用?C# Attachment.GetStreamBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attachment的用法示例。


在下文中一共展示了Attachment.GetStreamBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Attachment

            /// <summary>
            /// Initializes a new instance of the <see cref="Storage.Attachment" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            /// <param name="storageName">The name of the <see cref="Storage.NativeMethods.IStorage"/> stream that containts this attachment</param>
            internal Attachment(Storage message, string storageName) : base(message._storage)
            {
                StorageName = storageName;

                GC.SuppressFinalize(message);
                _propHeaderSize = MapiTags.PropertiesStreamHeaderAttachOrRecip;

                CreationTime = GetMapiPropertyDateTime(MapiTags.PR_CREATION_TIME);
                LastModificationTime = GetMapiPropertyDateTime(MapiTags.PR_LAST_MODIFICATION_TIME);

                ContentId = GetMapiPropertyString(MapiTags.PR_ATTACH_CONTENTID);
                IsInline = ContentId != null;

                var isContactPhoto = GetMapiPropertyBool(MapiTags.PR_ATTACHMENT_CONTACTPHOTO);
                if (isContactPhoto == null)
                    IsContactPhoto = false;
                else
                    IsContactPhoto = (bool) isContactPhoto;

                var renderingPosition = GetMapiPropertyInt32(MapiTags.PR_RENDERING_POSITION);
                if (renderingPosition == null)
                    RenderingPosition = -1;
                else
                    RenderingPosition = (int) renderingPosition;

                var fileName = GetMapiPropertyString(MapiTags.PR_ATTACH_LONG_FILENAME);

                if (string.IsNullOrEmpty(fileName))
                    fileName = GetMapiPropertyString(MapiTags.PR_ATTACH_FILENAME);

                if (string.IsNullOrEmpty(fileName))
                    fileName = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME);

                if (fileName != null)
                    FileName = FileManager.RemoveInvalidFileNameChars(fileName); 
                
                var attachmentMethod = GetMapiPropertyInt32(MapiTags.PR_ATTACH_METHOD);

                switch (attachmentMethod)
                {

                    case MapiTags.ATTACH_BY_REFERENCE:
                    case MapiTags.ATTACH_BY_REF_RESOLVE:
                    case MapiTags.ATTACH_BY_REF_ONLY:
                        ResolveAttachment();
                        break;
                    
                    case MapiTags.ATTACH_OLE:
                        var storage = GetMapiProperty(MapiTags.PR_ATTACH_DATA_BIN) as NativeMethods.IStorage;
                        var attachmentOle = new Attachment(new Storage(storage), null);
                        _data = attachmentOle.GetStreamBytes("CONTENTS");
                        var fileTypeInfo = FileTypeSelector.GetFileTypeFileInfo(Data);

                        if (string.IsNullOrEmpty(FileName))
                            FileName = fileTypeInfo.Description;

                        FileName += "." + fileTypeInfo.Extension.ToLower();
                        IsInline = true;
                        break;
                }
            }
开发者ID:iraychen,项目名称:MSGReader,代码行数:66,代码来源:Attachment.cs

示例2: GetAttachmentInfo

            /// <summary>
            /// Reads the neccesary attachment info as soon as the <see cref="FileName"/> or
            /// <see cref="Data"/> property gets accessed
            /// </summary>
            private void GetAttachmentInfo()
            {
                var fileName = GetMapiPropertyString(MapiTags.PR_ATTACH_LONG_FILENAME);

                if (string.IsNullOrEmpty(fileName))
                    fileName = GetMapiPropertyString(MapiTags.PR_ATTACH_FILENAME);

                if (string.IsNullOrEmpty(fileName))
                    fileName = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME);

                _fileName = FileManager.RemoveInvalidFileNameChars(fileName);

                var attachmentMethod = GetMapiPropertyInt32(MapiTags.PR_ATTACH_METHOD);

                switch (attachmentMethod)
                {
                    case MapiTags.ATTACH_OLE:
                        var storage = GetMapiProperty(MapiTags.PR_ATTACH_DATA_BIN) as NativeMethods.IStorage;
                        var attachmentOle = new Attachment(new Storage(storage));
                        try
                        {
                            _data = attachmentOle.GetStreamBytes("CONTENTS");
                            var fileTypeInfo = FileTypeSelector.GetFileTypeFileInfo(_data);
                            _fileName += "." + fileTypeInfo.Extension;
                        }
                        catch (Exception)
                        {
                            _data = null;
                        }
                        break;

                    default:
                        _data = GetMapiPropertyBytes(MapiTags.PR_ATTACH_DATA_BIN);
                        break;
                }
            }
开发者ID:naingyelin,项目名称:msgreader,代码行数:40,代码来源:Storage.cs


注:本文中的Attachment.GetStreamBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。