/// <summary> /// Creates meta information for a given file. /// </summary> /// <param name="localDirectory">The local directory.</param> /// <returns>A <see cref="VirtualFolderInfo"/> that matches the submitted directory.</returns> /// <exception cref="ArgumentNullException">If <paramref name="localDirectory"/> /// is a null reference.</exception> public static VirtualFolderInfo CreateFolderResourceInfo(this DirectoryInfo localDirectory) { Ensure.ArgumentNotNull(localDirectory, "localDirectory"); localDirectory.Refresh(); var item = new VirtualFolderInfo(); MapProperties(localDirectory, item); item.ParentFolderPath = localDirectory.Parent == null ? String.Empty : localDirectory.Parent.FullName; item.IsEmpty = localDirectory.IsEmpty(); return(item); }
/// <summary> /// Gets the parent folder of the resource. /// </summary> /// <returns>The parent of the resource.</returns> /// <exception cref="VirtualResourceNotFoundException">If the resource that is represented /// by this object does not exist in the file system.</exception> /// <exception cref="ResourceAccessException">In case of an invalid or prohibited /// resource access.</exception> public override VirtualFolder GetParentFolder() { VirtualFolderInfo folderInfo = Provider.GetFileParent(MetaData.FullName); return(new VirtualFolder(Provider, folderInfo)); }
/// <summary> /// Copies a given folder and all its contents to a new destination. /// </summary> /// <param name="folder">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="VirtualFolderInfo"/> object that represents the new /// directory in the file system.</returns> /// <exception cref="ArgumentNullException">If any of the parameters is a /// null reference.</exception> /// <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 VirtualFolderInfo CopyFolder(VirtualFolderInfo folder, string destinationPath) { Ensure.ArgumentNotNull(folder, "folder"); return(CopyFolder(folder.FullName, destinationPath)); }
/// <summary> /// Creates or updates a given file resource in the file system. /// </summary> /// <param name="parent">The designated parent folder, which /// needs to exists, and provide write access.</param> /// <param name="fileName">The name of the file to be created.</param> /// <param name="input">A stream that provides the file's contents.</param> /// <param name="overwrite">Whether an existing file should be overwritten /// or not. If this parameter is false and the file already exists, a /// <see cref="ResourceOverwriteException"/> is thrown.</param> /// <param name="resourceLength">The length of the resource to be uploaded in bytes.</param> /// <param name="contentType">The content type of the uploaded resource.</param> /// <exception cref="ResourceAccessException">In case of invalid or prohibited /// resource access.</exception> /// <exception cref="ResourceOverwriteException">If a file already exists at the /// specified location, and the <paramref name="overwrite"/> flag was not set.</exception> /// <exception cref="ArgumentNullException">If any of the parameters is a null reference.</exception> public virtual VirtualFileInfo WriteFile(VirtualFolderInfo parent, string fileName, Stream input, bool overwrite, long resourceLength, string contentType) { Ensure.ArgumentNotNull(parent, "parent"); return(WriteFile(parent.FullName, fileName, input, overwrite, resourceLength, contentType)); }
/// <summary> /// Creates a new folder in the file system. /// </summary> /// <param name="parent">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="parent"/> /// 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 the <paramref name="parent"/> /// folder does not exist.</exception> /// <exception cref="ResourceOverwriteException">If the folder already exists on the file /// system.</exception> public virtual VirtualFolderInfo CreateFolder(VirtualFolderInfo parent, string folderName) { Ensure.ArgumentNotNull(parent, "parent"); return(CreateFolder(parent.FullName, folderName)); }
/// <summary> /// Gets all files and folders of a given <paramref name="parent"/> folder that match /// the specified <paramref name="searchPattern"/>. /// </summary> /// <param name="parent">The processed parent folder.</param> /// <param name="searchPattern">A search string which is used to limit the returned /// results to folders with matching names.</param> /// <returns>The files and folders of the submitted parent.</returns> /// <exception cref="ArgumentNullException">If <paramref name="parent"/> /// is a null reference.</exception> /// <exception cref="ArgumentNullException">If <paramref name="searchPattern"/> /// is a null reference.</exception> /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented /// by <paramref name="parent"/> does not exist in the file system.</exception> /// <exception cref="ResourceAccessException">In case of invalid or prohibited /// resource access.</exception> public virtual FolderContentsInfo GetFolderContents(VirtualFolderInfo parent, string searchPattern) { Ensure.ArgumentNotNull(parent, "parent"); return(GetFolderContents(parent.FullName, searchPattern)); }
/// <summary> /// Gets all files and folders of a given <paramref name="parent"/> folder. /// </summary> /// <param name="parent">The processed parent folder.</param> /// <returns>The files and folders of the submitted parent.</returns> /// <exception cref="ArgumentNullException">If <paramref name="parent"/> /// is a null reference.</exception> /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented /// by <paramref name="parent"/> does not exist in the file system.</exception> /// <exception cref="ResourceAccessException">In case of invalid or prohibited /// resource access.</exception> public virtual FolderContentsInfo GetFolderContents(VirtualFolderInfo parent) { Ensure.ArgumentNotNull(parent, "parent"); return(GetFolderContents(parent.FullName)); }
/// <summary> /// Gets all files of a given <paramref name="parent"/> folder that match /// the specified <paramref name="searchPattern"/>. /// </summary> /// <param name="parent">The processed parent folder.</param> /// <param name="searchPattern">A search string which is used to limit the returned /// results to folders with matching names.</param> /// <returns>The files in the submitted <paramref name="parent"/> folder.</returns> /// <exception cref="ArgumentNullException">If <paramref name="parent"/> /// is a null reference.</exception> /// <exception cref="ArgumentNullException">If <paramref name="searchPattern"/> /// is a null reference.</exception> /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented /// by <paramref name="parent"/> does not exist in the file system.</exception> /// <exception cref="ResourceAccessException">In case of invalid or prohibited /// resource access.</exception> public virtual IEnumerable <VirtualFileInfo> GetChildFiles(VirtualFolderInfo parent, string searchPattern) { Ensure.ArgumentNotNull(parent, "parent"); return(GetChildFiles(parent.FullName, searchPattern)); }
/// <summary> /// Gets all files of a given <paramref name="parent"/> folder. /// </summary> /// <param name="parent">The processed parent folder.</param> /// <returns>The files in the submitted <paramref name="parent"/> folder.</returns> /// <exception cref="ArgumentNullException">If <paramref name="parent"/> /// is a null reference.</exception> /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented /// by <paramref name="parent"/> does not exist in the file system.</exception> /// <exception cref="ResourceAccessException">In case of invalid or prohibited /// resource access.</exception> public virtual IEnumerable <VirtualFileInfo> GetChildFiles(VirtualFolderInfo parent) { Ensure.ArgumentNotNull(parent, "parent"); return(GetChildFiles(parent.FullName)); }
/// <summary> /// Gets the parent folder of a given file system resource. /// </summary> /// <param name="child">An arbitrary folder resource of the file system.</param> /// <returns>The parent of the folder.</returns> /// <exception cref="ArgumentNullException">If <paramref name="child"/> /// is a null reference.</exception> /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented /// by <paramref name="child"/> does not exist in the file system.</exception> public virtual VirtualFolderInfo GetFolderParent(VirtualFolderInfo child) { Ensure.ArgumentNotNull(child, "child"); return(GetFolderParent(child.FullName)); }