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


C# Attachment.SaveAsFile方法代码示例

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


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

示例1: OpenActualDocumentFromPlaceHolder

        public bool OpenActualDocumentFromPlaceHolder(Attachment attachment)
        {
            try
            {
                if (attachment.Size > (1024*5))
                {
                    Logger.LogTrace("Returning without doing anything as the file size is > 5k");
                    return false;
                }

                using (var lcfm = new LocalCopyOfFileManager())
                {
                    string filename = lcfm.GetLocalCopyOfFileTarget(attachment.FileName);
                    attachment.SaveAsFile(filename);

                    Logger.LogTrace("Saving placeholder file to " + filename);
                    var lah = new LargeAttachmentHelper(filename);
                    if (lah.IsLargeAttachment)
                    {
                        Logger.LogTrace("Opening actual file from" + lah.ActualPath);
                        var startInfo = new ProcessStartInfo();
                        startInfo.FileName = lah.ActualPath;
                        Process.Start(startInfo);
                        return true;
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                throw;
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:34,代码来源:BigAttachmentsManager.cs

示例2: Save

        public string Save(string filename, Attachment attach)
        {
            string pos = "TemporaryStorage.Save - ";

            log.Info(pos + "INIT");

            System.Guid guid = System.Guid.NewGuid();

            fileFolder = Path.Combine(Constants.getWorkFolder(), guid.ToString());
            fullFileName = Path.Combine(fileFolder, filename);

            log.Info(pos + "Creo la dir di appoggio:" + fileFolder);
            Directory.CreateDirectory(fileFolder);

            log.Info(pos + "Salvo il file:" + fullFileName);

            attach.SaveAsFile(fullFileName);

            log.Info(pos + "END");

            return fullFileName;
        }
开发者ID:webscience,项目名称:K-people,代码行数:22,代码来源:TemporaryStorage.cs

示例3: IsLargeAttachmentFile

        public static bool IsLargeAttachmentFile(Attachment attachment)
        {
            if (Path.HasExtension(attachment.FileName) && Path.GetExtension(attachment.FileName).ToLower() == ".wsl")
            {
                using (var lcfm = new LocalCopyOfFileManager())
                {
                    var tempFile = lcfm.GetLocalCopyOfFileTarget(attachment.FileName);
                    attachment.SaveAsFile(tempFile);

                    var lah = new LargeAttachmentHelper(tempFile);
                    return lah.IsLargeAttachment;
                }
            }
            return false;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:15,代码来源:Utils.cs

示例4: GetAttachmentLength

        private long GetAttachmentLength(Attachment attachment)
        {
            string sTempFile = Path.GetTempFileName();
            attachment.SaveAsFile(sTempFile);

            StructuredStorageInterface.IStorage storage = null;
            StructuredStorageInterface.StgOpenStorage(sTempFile, null,
                StructuredStorageInterface.ReadWriteMode, System.IntPtr.Zero, 0, out storage);

            storage.Commit(StructuredStorageInterface.STGC_CONSOLIDATE);

            System.Runtime.InteropServices.Marshal.ReleaseComObject(storage);

            FileInfo fi = new FileInfo(sTempFile);
            long iLength = fi.Length;
            System.IO.File.Delete(sTempFile);
            return iLength;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:18,代码来源:TestEmail_EATTests.cs


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