Example #1
0
 public AttachViewData(Int32 id, String name, Attachment att)
 {
     Id = id;
     Name = name;
     HasData = id>0;
     if (att != null)
     {
         FilePath = att.PathName;
         FileName = att.FileName;
         FullPath = GetFilePath();
         HasAttach = true;
     }
 }
        public void DeleteFileAttachment(Attachment attachment)
        {
            var filePath = _storageRoot + attachment.PathName + "//" + attachment.FileName;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                repositoriesContainer.AttachmentRepository.Delete(attachment);
                repositoriesContainer.ApplyChanges();
            }

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
        }
        private void SaveFile(Attachment attachment, string folder)
        {
            var targetDirectoty = Path.Combine(_storageRoot, folder);
            var tempFilePath = Path.Combine(_tempStorageRoot, attachment.FileName);
            var targetFilePath = Path.Combine(targetDirectoty, attachment.FileName);

            if (!Directory.Exists(targetDirectoty))
            {
                Directory.CreateDirectory(targetDirectoty);
            }

            if (File.Exists(tempFilePath))
            {
                File.Copy(tempFilePath, targetFilePath, true);
                File.Delete(tempFilePath);
            }
        }