/// <summary>
 /// Creates a new instance which refers to a given <see cref="VirtualFileInfo"/>
 /// item.
 /// </summary>
 /// <exception cref="ArgumentNullException">If <paramref name="fileInfo"/>
 /// is a null reference.</exception>
 public FileOperationResult(VirtualFileInfo fileInfo)
 {
     if (fileInfo == null)
     {
         throw new ArgumentNullException("fileInfo");
     }
     FileInfo = fileInfo;
 }
Exemple #2
0
        /// <summary>
        /// Creates meta information for a given file.
        /// </summary>
        /// <param name="localFile">The local file.</param>
        /// <returns>A <see cref="VirtualFileInfo"/> that matches the submitted file.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="localFile"/>
        /// is a null reference.</exception>
        public static VirtualFileInfo CreateFileResourceInfo(this FileInfo localFile)
        {
            if (localFile == null)
            {
                throw new ArgumentNullException("localFile");
            }
            localFile.Refresh();
            var item = new VirtualFileInfo
            {
                Length           = localFile.Exists ? localFile.Length : 0,
                ContentType      = ContentUtil.ResolveContentType(localFile.Extension),
                ParentFolderPath = localFile.DirectoryName,
            };

            MapProperties(localFile, item);
            return(item);
        }
 /// <summary>
 /// Creates a new instance which refers to a given <see cref="VirtualFileInfo"/>
 /// item.
 /// </summary>
 /// <exception cref="ArgumentNullException">If <paramref name="fileInfo"/>
 /// is a null reference.</exception>
 public FileOperationResult(VirtualFileInfo fileInfo)
 {
   if (fileInfo == null) throw new ArgumentNullException("fileInfo");
   FileInfo = fileInfo;
 }
 /// <summary>
 /// Copies a given file to a new destination.
 /// </summary>
 /// <param name="file">Represents the resource in the file system.</param>
 /// <param name="destinationPath">The new path of the resource. Can be another name
 /// for the resource itself.</param>
 /// <returns>A <see cref="VirtualFileInfo"/> object that represents the new
 /// file in the file system.</returns>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access, or if the operation is not possible (e.g. a resource being
 /// moved/copied to itself).</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the resource that
 /// should be moved does not exist in the file system.</exception>
 /// <exception cref="ResourceOverwriteException">If a resource that matches the
 /// submitted <paramref name="destinationPath"/> already exists.</exception>
 public virtual VirtualFileInfo CopyFile(VirtualFileInfo file, string destinationPath)
 {
     Ensure.ArgumentNotNull(file, "file");
     return(CopyFile(file.FullName, destinationPath));
 }
 /// <summary>
 /// Gets the parent folder of a given file system resource.
 /// </summary>
 /// <param name="child">An arbitrary file resource of the file system.</param>
 /// <returns>The parent of the file.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="child"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the file that is represented
 /// by <paramref name="child"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of an invalid or prohibited
 /// resource access.</exception>
 public virtual VirtualFolderInfo GetFileParent(VirtualFileInfo child)
 {
     Ensure.ArgumentNotNull(child, "child");
     return(GetFileParent(child.FullName));
 }
 /// <summary>
 /// Gets the binary contents as a stream in a blocking operation.
 /// Use the methods in <see cref="ContentUtil"/> class for simplified stream
 /// handling.
 /// </summary>
 /// <param name="fileInfo">Provides meta information about the file to be read.</param>
 /// <returns>A stream that allows the contents of the file to be read.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="fileInfo"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the file that is represented
 /// by <paramref name="fileInfo"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public virtual Stream ReadFileContents(VirtualFileInfo fileInfo)
 {
     Ensure.ArgumentNotNull(fileInfo, "fileInfo");
     return(ReadFileContents(fileInfo.FullName));
 }