Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public static void RemoveAttachment(Attachment attachment)
 {
     File.Delete(attachment.Path);
 }