本文整理汇总了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;
}