public void Creating_Item_From_Inexisting_Folder_Should_Provides_Names_And_Default_Properties()
    {
      DirectoryInfo di = new DirectoryInfo("test");
      Assert.IsFalse(di.Exists);

      VirtualFolderInfo item = di.CreateFolderResourceInfo();
      Assert.AreEqual("test", item.Name);
      Assert.AreEqual(di.FullName, item.FullName);

      //timestamps should be null
      Assert.IsNull(item.CreationTime);
      Assert.IsNull(item.LastAccessTime);
      Assert.IsNull(item.LastWriteTime);

      //the item should not be hidden / readonly
      Assert.IsFalse(item.IsHidden);
      Assert.IsFalse(item.IsReadOnly);

      //item is not root folder
      Assert.IsFalse(item.IsRootFolder);
    }
    /// <summary>
    /// Creates a new folder in the file system.
    /// </summary>
    /// <param name="parentFolderPath">The qualified name of the designated parent folder, which
    /// needs to exists, and provide write access.</param>
    /// <param name="folderName">The name of the folder to be created.</param>
    /// <returns>A <see cref="VirtualFileInfo"/> instance which represents
    /// the created folder.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="parentFolderPath"/>
    /// is a null reference.</exception>
    /// <exception cref="ArgumentNullException">If <paramref name="folderName"/>
    /// is a null reference.</exception>
    /// <exception cref="ResourceAccessException">In case of invalid or prohibited
    /// resource access.</exception>
    /// <exception cref="VirtualResourceNotFoundException">If no folder exists that
    /// matches the submitted <paramref name="parentFolderPath"/>.</exception>
    /// <exception cref="ResourceOverwriteException">If the folder already exists on the file
    /// system.</exception>
    public override VirtualFolderInfo CreateFolder(string parentFolderPath, string folderName)
    {
      if (parentFolderPath == null) throw new ArgumentNullException("parentFolderPath");
      if (folderName == null) throw new ArgumentNullException("folderName");

      string absoluteParentPath;
      var parent = GetFolderInfoInternal(parentFolderPath, true, out absoluteParentPath);

      if (RootDirectory == null && parent.IsRootFolder)
      {
        VfsLog.Debug("Blocked attempt to create a folder '{0}' at system root.", folderName);
        throw new ResourceAccessException("Folders cannot be created at the system root.");
      }
      
      //create path of the child
      string childPath = PathUtil.GetAbsolutePath(folderName, new DirectoryInfo(absoluteParentPath));

      //make sure the folder name is not a relative path that points outside the scope
      if (RootDirectory != null && !RootDirectory.IsParentOf(childPath))
      {
        string msg = "Blocked attempt to create folder outside of root through with parent '{0}' and folder name '{1}'";
        VfsLog.Warn(msg, absoluteParentPath, folderName);

        throw new ResourceAccessException("Invalid file path: " + folderName);
      }

      var directory = new DirectoryInfo(childPath);
      if (directory.Exists)
      {
        //log and create exception if the directory already exists
        VfsLog.Debug("Blocked attempt to recreate directory '{0}'", directory.FullName);
        string relativePath = PathUtil.GetRelativePath(childPath, RootDirectory);
        string msg = String.Format("The folder '{0}' already exists.", relativePath);
        throw new ResourceOverwriteException(msg);
      }

      try
      {
        //create directory
        directory.Create();
      }
      catch (Exception e)
      {
        const string msg = "Exception occurred when trying to create new folder '{0}' for parent '{1}'";
        VfsLog.Debug(e, msg, folderName, parent.FullName);

        throw new ResourceAccessException("Could not create folder", e);
      }

      var folder = directory.CreateFolderResourceInfo();

      //adjust and return
      if (UseRelativePaths) folder.MakePathsRelativeTo(RootDirectory);
      return folder;
    }
    protected VirtualFolderInfo GetFolderInfoInternal(string virtualFolderPath, bool mustExist, out string absolutePath)
    {
      try
      {
        //make sure we operate on absolute paths
        absolutePath = PathUtil.GetAbsolutePath(virtualFolderPath ?? "", RootDirectory);

        if (IsRootPath(absolutePath))
        {
          return GetFileSystemRoot();
        }

        var di = new DirectoryInfo(absolutePath);
        VirtualFolderInfo folderInfo = di.CreateFolderResourceInfo();

        //convert to relative paths if required (also prevents qualified paths in validation exceptions)
        if (UseRelativePaths) folderInfo.MakePathsRelativeTo(RootDirectory);

        //make sure the user is allowed to access the resource
        ValidateResourceAccess(folderInfo);

        //verify folder exists on FS
        if(mustExist) folderInfo.VerifyDirectoryExists(RootDirectory);

        return folderInfo;
      }
      catch (VfsException)
      {
        //just bubble internal exceptions
        throw;
      }
      catch (Exception e)
      {
        VfsLog.Debug(e, "Could not create directory based on path '{0}' with root '{1}'", virtualFolderPath,
                           RootDirectory);
        throw new ResourceAccessException("Invalid path submitted: " + virtualFolderPath);
      }
    }
        public  FolderItem ResolveFolderResourcePath2(string submittedFolderPath, FileSystemTask context) {
            //make sure we operate on absolute paths
            string absolutePath = PathUtil.GetAbsolutePath(submittedFolderPath ?? "", RootDirectory);

            if (IsRootPath(absolutePath)) {
                return GetFileSystemRootImplementation() as FolderItem;
            }

            var di = new DirectoryInfo(absolutePath);
            VirtualFolderInfo folderInfo = di.CreateFolderResourceInfo();

            var item = new FolderItem(di, folderInfo);

            //convert to relative paths if required (also prevents qualified paths in validation exceptions)
            if (UseRelativePaths) item.MakePathsRelativeTo(RootDirectory);

            ValidateFolderRequestAccess(item, submittedFolderPath, context);
            return item;
        }