Example #1
0
 public static void SaveUploadedFiles(FileSystemNode directory, IFormFileCollection uploadedFiles)
 {
     if (directory.IsDirectory)
     {
         foreach (IFormFile uploadedFile in uploadedFiles)
         {
             using (FileStream fileStream = File.Open(Path.Combine(directory.NodePath, uploadedFile.FileName), FileMode.OpenOrCreate, FileAccess.Write))
             {
                 uploadedFile.CopyTo(fileStream);
             }
         }
     }
 }
Example #2
0
        public static FileSystemNode Delete(FileSystemNode node)
        {
            if (node.NodePath.Equals(root))
            {
                return(node);
            }

            if (node.IsFile)
            {
                File.Delete(node.NodePath);
            }
            else if (node.IsDirectory)
            {
                Directory.Delete(node.NodePath, true);
            }
            return(new FileSystemNode(Path.GetDirectoryName(node.NodePath), systemMimeMapper));
        }
Example #3
0
        public static FileSystemNode Move(FileSystemNode node, string newLocation)
        {
            if (node.NodePath.Equals(root))
            {
                return(node);
            }

            string newPath = Path.Combine(root, newLocation, node.Name);

            if (node.IsFile)
            {
                File.Move(node.NodePath, newPath);
            }
            else if (node.IsDirectory)
            {
                Directory.Move(node.NodePath, newPath);
            }
            return(new FileSystemNode(newPath, systemMimeMapper));
        }