本文整理匯總了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;
}
}
示例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;
}
示例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;
}
示例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;
}