public static Attachment AddAttachment(HttpPostedFileBase file, Ticket ticket) { var filePath = GetFilePath(file, ticket); var directoryPath = new FileInfo(filePath).Directory.FullName; Directory.CreateDirectory(directoryPath); file.SaveAs(filePath); var attachment = new Attachment { Name = Path.GetFileName(file.FileName), Path = filePath }; return attachment; }
public static void RemoveAttachment(Attachment attachment) { File.Delete(attachment.Path); }