當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。