Search Results for

    Show / Hide Table of Contents

    Class FileFolderExtensions

    Class that holds the file and folder methods

    Inheritance
    System.Object
    FileFolderExtensions
    Namespace: Microsoft.SharePoint.Client
    Assembly: PnP.Framework.dll
    Syntax
    public static class FileFolderExtensions : object

    Methods

    ApproveFile(Web, String, String)

    Approves a file

    Declaration
    public static void ApproveFile(this Web web, string serverRelativeUrl, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to approve

    System.String comment

    Message to be recorded with the approval

    ApproveFileAsync(Web, String, String)

    Approves a file

    Declaration
    public static async Task ApproveFileAsync(this Web web, string serverRelativeUrl, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to approve

    System.String comment

    Message to be recorded with the approval

    Returns
    Task

    CheckInFile(Web, String, CheckinType, String)

    Checks in a file

    Declaration
    public static void CheckInFile(this Web web, string serverRelativeUrl, CheckinType checkinType, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to checkin

    CheckinType checkinType

    The type of the checkin

    System.String comment

    Message to be recorded with the approval

    CheckInFileAsync(Web, String, CheckinType, String)

    Checks in a file

    Declaration
    public static async Task CheckInFileAsync(this Web web, string serverRelativeUrl, CheckinType checkinType, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to checkin

    CheckinType checkinType

    The type of the checkin

    System.String comment

    Message to be recorded with the approval

    Returns
    Task

    CheckInFileImplementation(Web, String, CheckinType, String)

    Checks in a file

    Declaration
    public static async Task CheckInFileImplementation(this Web web, string serverRelativeUrl, CheckinType checkinType, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to checkin

    CheckinType checkinType

    The type of the checkin

    System.String comment

    Message to be recorded with the approval

    Returns
    Task

    CheckOutFile(Web, String)

    Checks out a file

    Declaration
    public static void CheckOutFile(this Web web, string serverRelativeUrl)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to checkout

    CheckOutFileAsync(Web, String)

    Checks out a file

    Declaration
    public static async Task CheckOutFileAsync(this Web web, string serverRelativeUrl)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to checkout

    Returns
    Task

    ConvertFolderToDocumentSet(List, Folder)

    Converts a folder with the given name as a child of the List RootFolder.

    Declaration
    public static Folder ConvertFolderToDocumentSet(this List list, Folder folder)
    Parameters
    List list

    List in which the folder exists

    Folder folder

    Folder to convert

    Returns
    Folder

    The newly converted Document Set, so that additional operations (such as setting properties) can be done.

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    ConvertFolderToDocumentSet(List, String)

    Converts a folder with the given name as a child of the List RootFolder.

    Declaration
    public static Folder ConvertFolderToDocumentSet(this List list, string folderName)
    Parameters
    List list

    List in which the folder exists

    System.String folderName

    Folder name to convert

    Returns
    Folder

    The newly converted Document Set, so that additional operations (such as setting properties) can be done.

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    ConvertFolderToDocumentSetAsync(List, Folder)

    Converts a folder with the given name as a child of the List RootFolder.

    Declaration
    public static async Task<Folder> ConvertFolderToDocumentSetAsync(this List list, Folder folder)
    Parameters
    List list

    List in which the folder exists

    Folder folder

    Folder to convert

    Returns
    Task<Folder>

    The newly converted Document Set, so that additional operations (such as setting properties) can be done.

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    ConvertFolderToDocumentSetAsync(List, String)

    Converts a folder with the given name as a child of the List RootFolder.

    Declaration
    public static async Task<Folder> ConvertFolderToDocumentSetAsync(this List list, string folderName)
    Parameters
    List list

    List in which the folder exists

    System.String folderName

    Folder name to convert

    Returns
    Task<Folder>

    The newly converted Document Set, so that additional operations (such as setting properties) can be done.

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    CreateDocumentSet(Folder, String, ContentTypeId)

    Creates a new document set as a child of an existing folder, with the specified content type ID.

    Declaration
    public static Folder CreateDocumentSet(this Folder folder, string documentSetName, ContentTypeId contentTypeId)
    Parameters
    Folder folder

    Folder of the document set

    System.String documentSetName

    Name of the document set

    ContentTypeId contentTypeId

    Content type of the document set

    Returns
    Folder

    The created Folder representing the document set, so that additional operations (such as setting properties) can be done.

    Remarks
    var setContentType = list.BestMatchContentTypeId(BuiltInContentTypeId.DocumentSet); var set1 = list.RootFolder.CreateDocumentSet("Set 1", setContentType);

    CreateDocumentSetAsync(Folder, String, ContentTypeId)

    Creates a new document set as a child of an existing folder, with the specified content type ID.

    Declaration
    public static async Task<Folder> CreateDocumentSetAsync(this Folder folder, string documentSetName, ContentTypeId contentTypeId)
    Parameters
    Folder folder

    Folder of the document set

    System.String documentSetName

    Name of the document set

    ContentTypeId contentTypeId

    Content type of the document set

    Returns
    Task<Folder>

    The created Folder representing the document set, so that additional operations (such as setting properties) can be done.

    Remarks
    var setContentType = list.BestMatchContentTypeId(BuiltInContentTypeId.DocumentSet); var set1 = list.RootFolder.CreateDocumentSet("Set 1", setContentType);

    CreateFolder(Folder, String)

    Creates a folder with the given name.

    Declaration
    public static Folder CreateFolder(this Folder parentFolder, string folderName)
    Parameters
    Folder parentFolder

    Parent folder to create under

    System.String folderName

    Folder name to retrieve or create

    Returns
    Folder

    The newly created folder

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    var folder = list.RootFolder.CreateFolder("new-folder");

    CreateFolder(Web, String)

    Creates a folder with the given name as a child of the Web. Note it is more common to create folders within an existing Folder, such as the RootFolder of a List.

    Declaration
    public static Folder CreateFolder(this Web web, string folderName)
    Parameters
    Web web

    Web to check for the named folder

    System.String folderName

    Folder name to retrieve or create

    Returns
    Folder

    The newly created Folder, so that additional operations (such as setting properties) can be done.

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    CreateFolderAsync(Folder, String)

    Creates a folder with the given name.

    Declaration
    public static async Task<Folder> CreateFolderAsync(this Folder parentFolder, string folderName)
    Parameters
    Folder parentFolder

    Parent folder to create under

    System.String folderName

    Folder name to retrieve or create

    Returns
    Task<Folder>

    The newly created folder

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    var folder = list.RootFolder.CreateFolder("new-folder");

    CreateFolderAsync(Web, String)

    Creates a folder with the given name as a child of the Web. Note it is more common to create folders within an existing Folder, such as the RootFolder of a List.

    Declaration
    public static async Task<Folder> CreateFolderAsync(this Web web, string folderName)
    Parameters
    Web web

    Web to check for the named folder

    System.String folderName

    Folder name to retrieve or create

    Returns
    Task<Folder>

    The newly created Folder, so that additional operations (such as setting properties) can be done.

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    DoesFolderExists(Web, String)

    Checks if a specific folder exists

    Declaration
    public static bool DoesFolderExists(this Web web, string serverRelativeFolderUrl)
    Parameters
    Web web

    The web to process

    System.String serverRelativeFolderUrl

    Folder to check

    Returns
    System.Boolean

    Returns true if folder exists

    DoesFolderExistsAsync(Web, String)

    Checks if a specific folder exists

    Declaration
    public static async Task<bool> DoesFolderExistsAsync(this Web web, string serverRelativeFolderUrl)
    Parameters
    Web web

    The web to process

    System.String serverRelativeFolderUrl

    Folder to check

    Returns
    Task<System.Boolean>

    Returns true if folder exists

    EnsureFolder(Folder, String, Expression<Func<Folder, Object>>[])

    Checks if the subfolder exists, and if it does not exist creates it.

    Declaration
    public static Folder EnsureFolder(this Folder parentFolder, string folderName, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Folder parentFolder

    Parent folder to create under

    System.String folderName

    Folder name to retrieve or create

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Folder

    The existing or newly created folder

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    EnsureFolder(Web, Folder, String, Expression<Func<Folder, Object>>[])

    Ensure that the folder structure is created. This also ensures hierarchy of folders.

    Declaration
    public static Folder EnsureFolder(this Web web, Folder parentFolder, string folderPath, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to be processed - can be root web or sub site

    Folder parentFolder

    Parent folder

    System.String folderPath

    Folder path

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Folder

    The folder structure

    EnsureFolder(Web, String, Expression<Func<Folder, Object>>[])

    Checks if the folder exists at the top level of the web site, and if it does not exist creates it. Note it is more common to create folders within an existing Folder, such as the RootFolder of a List.

    Declaration
    public static Folder EnsureFolder(this Web web, string folderName, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to check for the named folder

    System.String folderName

    Folder name to retrieve or create

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Folder

    The existing or newly created folder

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    EnsureFolderAsync(Folder, String, Expression<Func<Folder, Object>>[])

    Checks if the subfolder exists, and if it does not exist creates it.

    Declaration
    public static async Task<Folder> EnsureFolderAsync(this Folder parentFolder, string folderName, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Folder parentFolder

    Parent folder to create under

    System.String folderName

    Folder name to retrieve or create

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Task<Folder>

    The existing or newly created folder

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    EnsureFolderAsync(Web, Folder, String, Expression<Func<Folder, Object>>[])

    Ensure that the folder structure is created. This also ensures hierarchy of folders.

    Declaration
    public static async Task<Folder> EnsureFolderAsync(this Web web, Folder parentFolder, string folderPath, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to be processed - can be root web or sub site

    Folder parentFolder

    Parent folder

    System.String folderPath

    Folder path

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Task<Folder>

    The folder structure

    EnsureFolderAsync(Web, String, Expression<Func<Folder, Object>>[])

    Checks if the folder exists at the top level of the web site, and if it does not exist creates it. Note it is more common to create folders within an existing Folder, such as the RootFolder of a List.

    Declaration
    public static async Task<Folder> EnsureFolderAsync(this Web web, string folderName, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to check for the named folder

    System.String folderName

    Folder name to retrieve or create

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Task<Folder>

    The existing or newly created folder

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    EnsureFolderImplementation(Web, Folder, String, Expression<Func<Folder, Object>>[])

    Ensure that the folder structure is created. This also ensures hierarchy of folders.

    Declaration
    public static async Task<Folder> EnsureFolderImplementation(this Web web, Folder parentFolder, string folderPath, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to be processed - can be root web or sub site

    Folder parentFolder

    Parent folder

    System.String folderPath

    Folder path

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Task<Folder>

    The folder structure

    EnsureFolderPath(Web, String, Expression<Func<Folder, Object>>[])

    Check if a folder exists with the specified path (relative to the web), and if not creates it (inside a list if necessary)

    Declaration
    public static Folder EnsureFolderPath(this Web web, string webRelativeUrl, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to check for the specified folder

    System.String webRelativeUrl

    Path to the folder, relative to the web site

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Folder

    The existing or newly created folder

    Remarks

    If the specified path is inside an existing list, then the folder is created inside that list.

    Any existing folders are traversed, and then any remaining parts of the path are created as new folders.

    EnsureFolderPathAsync(Web, String, Expression<Func<Folder, Object>>[])

    Check if a folder exists with the specified path (relative to the web), and if not creates it (inside a list if necessary)

    Declaration
    public static async Task<Folder> EnsureFolderPathAsync(this Web web, string webRelativeUrl, params Expression<Func<Folder, object>>[] expressions)
    Parameters
    Web web

    Web to check for the specified folder

    System.String webRelativeUrl

    Path to the folder, relative to the web site

    Expression<Func<Folder, System.Object>>[] expressions

    List of lambda expressions of properties to load when retrieving the object

    Returns
    Task<Folder>

    The existing or newly created folder

    Remarks

    If the specified path is inside an existing list, then the folder is created inside that list.

    Any existing folders are traversed, and then any remaining parts of the path are created as new folders.

    FindFiles(Folder, String)

    Find files in a specific folder

    Declaration
    public static List<File> FindFiles(this Folder folder, string match)
    Parameters
    Folder folder

    The folder to process

    System.String match

    a wildcard pattern to match

    Returns
    List<File>

    A list with the found objects

    FindFiles(List, String)

    Find files in the list, Can be slow.

    Declaration
    public static List<File> FindFiles(this List list, string match)
    Parameters
    List list

    The list to process

    System.String match

    a wildcard pattern to match

    Returns
    List<File>

    A list with the found objects

    FindFiles(Web, String)

    Finds files in the web. Can be slow.

    Declaration
    public static List<File> FindFiles(this Web web, string match)
    Parameters
    Web web

    The web to process

    System.String match

    a wildcard pattern to match

    Returns
    List<File>

    A list with the found objects

    FindFilesAsync(Folder, String)

    Find files in a specific folder

    Declaration
    public static async Task<List<File>> FindFilesAsync(this Folder folder, string match)
    Parameters
    Folder folder

    The folder to process

    System.String match

    a wildcard pattern to match

    Returns
    Task<List<File>>

    A list with the found objects

    FindFilesAsync(List, String)

    Find files in the list, Can be slow.

    Declaration
    public static async Task<List<File>> FindFilesAsync(this List list, string match)
    Parameters
    List list

    The list to process

    System.String match

    a wildcard pattern to match

    Returns
    Task<List<File>>

    A list with the found objects

    FindFilesAsync(Web, String)

    Finds files in the web. Can be slow.

    Declaration
    public static async Task<List<File>> FindFilesAsync(this Web web, string match)
    Parameters
    Web web

    The web to process

    System.String match

    a wildcard pattern to match

    Returns
    Task<List<File>>

    A list with the found objects

    FolderExists(Folder, String)

    Checks if the subfolder exists.

    Declaration
    public static bool FolderExists(this Folder parentFolder, string folderName)
    Parameters
    Folder parentFolder

    Parent folder to check for the named subfolder

    System.String folderName

    Folder name to retrieve

    Returns
    System.Boolean

    true if the folder exists; false otherwise

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    FolderExists(Web, String)

    Checks if the folder exists at the top level of the web site.

    Declaration
    public static bool FolderExists(this Web web, string folderName)
    Parameters
    Web web

    Web to check for the named folder

    System.String folderName

    Folder name to retrieve

    Returns
    System.Boolean

    true if the folder exists; false otherwise

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    FolderExistsAsync(Folder, String)

    Checks if the subfolder exists.

    Declaration
    public static async Task<bool> FolderExistsAsync(this Folder parentFolder, string folderName)
    Parameters
    Folder parentFolder

    Parent folder to check for the named subfolder

    System.String folderName

    Folder name to retrieve

    Returns
    Task<System.Boolean>

    true if the folder exists; false otherwise

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    FolderExistsAsync(Web, String)

    Checks if the folder exists at the top level of the web site.

    Declaration
    public static async Task<bool> FolderExistsAsync(this Web web, string folderName)
    Parameters
    Web web

    Web to check for the named folder

    System.String folderName

    Folder name to retrieve

    Returns
    Task<System.Boolean>

    true if the folder exists; false otherwise

    Remarks

    Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

    GetFile(Folder, String)

    Gets a file in a document library.

    Declaration
    public static File GetFile(this Folder folder, string fileName)
    Parameters
    Folder folder

    Folder containing the target file.

    System.String fileName

    File name.

    Returns
    File

    The target file if found, null if no file is found.

    GetFileAsString(Web, String)

    Returns a file as string

    Declaration
    public static string GetFileAsString(this Web web, string serverRelativeUrl)
    Parameters
    Web web

    The Web to process

    System.String serverRelativeUrl

    The server relative URL to the file

    Returns
    System.String

    The file contents as a string

    GetFileAsStringAsync(Web, String)

    Returns a file as string

    Declaration
    public static async Task<string> GetFileAsStringAsync(this Web web, string serverRelativeUrl)
    Parameters
    Web web

    The Web to process

    System.String serverRelativeUrl

    The server relative URL to the file

    Returns
    Task<System.String>

    The file contents as a string

    GetFileAsync(Folder, String)

    Gets a file in a document library.

    Declaration
    public static async Task<File> GetFileAsync(this Folder folder, string fileName)
    Parameters
    Folder folder

    Folder containing the target file.

    System.String fileName

    File name.

    Returns
    Task<File>

    The target file if found, null if no file is found.

    PublishFile(Web, String, String)

    Publishes a file existing on a server URL

    Declaration
    public static void PublishFile(this Web web, string serverRelativeUrl, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    the server relative URL of the file to publish

    System.String comment

    Comment recorded with the publish action

    PublishFileAsync(Web, String, String)

    Publishes a file existing on a server URL

    Declaration
    public static async Task PublishFileAsync(this Web web, string serverRelativeUrl, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    the server relative URL of the file to publish

    System.String comment

    Comment recorded with the publish action

    Returns
    Task

    PublishFileToLevel(File, FileLevel)

    Publishes a file based on the type of versioning required on the parent library.

    Declaration
    public static void PublishFileToLevel(this File file, FileLevel level)
    Parameters
    File file

    Target file to publish.

    FileLevel level

    Target publish direction (Draft and Published only apply, Checkout is ignored).

    PublishFileToLevelAsync(File, FileLevel)

    Publishes a file based on the type of versioning required on the parent library.

    Declaration
    public static async Task PublishFileToLevelAsync(this File file, FileLevel level)
    Parameters
    File file

    Target file to publish.

    FileLevel level

    Target publish direction (Draft and Published only apply, Checkout is ignored).

    Returns
    Task

    ResetFileToPreviousVersion(Web, String, CheckinType, String)

    Resets a file to its previous version.

    Declaration
    public static void ResetFileToPreviousVersion(this Web web, string serverRelativeUrl, CheckinType checkinType, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to process

    CheckinType checkinType

    The type of the checkin

    System.String comment

    Message to be recorded with the approval

    ResetFileToPreviousVersionAsync(Web, String, CheckinType, String)

    Resets a file to its previous version.

    Declaration
    public static async Task ResetFileToPreviousVersionAsync(this Web web, string serverRelativeUrl, CheckinType checkinType, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to process

    CheckinType checkinType

    The type of the checkin

    System.String comment

    Message to be recorded with the approval

    Returns
    Task

    ResetFileToPreviousVersionImplementation(Web, String, CheckinType, String)

    Checks in a file

    Declaration
    public static async Task ResetFileToPreviousVersionImplementation(this Web web, string serverRelativeUrl, CheckinType checkinType, string comment)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to checkin

    CheckinType checkinType

    The type of the checkin

    System.String comment

    Message to be recorded with the approval

    Returns
    Task

    ResolveSubFolder(Folder, String)

    Gets a folder with a given name in a given

    Declaration
    public static Folder ResolveSubFolder(this Folder folder, string folderName)
    Parameters
    Folder folder

    in which to search for

    System.String folderName

    Name of the folder to search for

    Returns
    Folder

    The found if available, null otherwise

    ResolveSubFolderAsync(Folder, String)

    Gets a folder with a given name in a given

    Declaration
    public static async Task<Folder> ResolveSubFolderAsync(this Folder folder, string folderName)
    Parameters
    Folder folder

    in which to search for

    System.String folderName

    Name of the folder to search for

    Returns
    Task<Folder>

    The found if available, null otherwise

    SaveFileToLocal(Web, String, String, String, Func<String, Boolean>)

    Saves a remote file to a local folder

    Declaration
    public static void SaveFileToLocal(this Web web, string serverRelativeUrl, string localPath, string localFileName = null, Func<string, bool> fileExistsCallBack = null)
    Parameters
    Web web

    The Web to process

    System.String serverRelativeUrl

    The server relative URL to the file

    System.String localPath

    The local folder

    System.String localFileName

    The local filename. If null the filename of the file on the server will be used

    Func<System.String, System.Boolean> fileExistsCallBack

    Optional callback function allowing to provide feedback if the file should be overwritten if it exists. The function requests a bool as return value and the string input contains the name of the file that exists.

    SaveFileToLocalAsync(Web, String, String, String, Func<String, Boolean>)

    Saves a remote file to a local folder

    Declaration
    public static async Task SaveFileToLocalAsync(this Web web, string serverRelativeUrl, string localPath, string localFileName = null, Func<string, bool> fileExistsCallBack = null)
    Parameters
    Web web

    The Web to process

    System.String serverRelativeUrl

    The server relative URL to the file

    System.String localPath

    The local folder

    System.String localFileName

    The local filename. If null the filename of the file on the server will be used

    Func<System.String, System.Boolean> fileExistsCallBack

    Optional callback function allowing to provide feedback if the file should be overwritten if it exists. The function requests a bool as return value and the string input contains the name of the file that exists.

    Returns
    Task

    SaveFileToLocalImplementation(Web, String, String, String, Func<String, Boolean>)

    Saves a remote file to a local folder

    Declaration
    public static async Task SaveFileToLocalImplementation(this Web web, string serverRelativeUrl, string localPath, string localFileName = null, Func<string, bool> fileExistsCallBack = null)
    Parameters
    Web web

    The Web to process

    System.String serverRelativeUrl

    The server relative URL to the file

    System.String localPath

    The local folder

    System.String localFileName

    The local filename. If null the filename of the file on the server will be used

    Func<System.String, System.Boolean> fileExistsCallBack

    Optional callback function allowing to provide feedback if the file should be overwritten if it exists. The function requests a bool as return value and the string input contains the name of the file that exists.

    Returns
    Task

    SetFileProperties(File, IDictionary<String, String>, Boolean)

    Sets file properties using a dictionary.

    Declaration
    public static void SetFileProperties(this File file, IDictionary<string, string> properties, bool checkoutIfRequired = true)
    Parameters
    File file

    Target file object.

    IDictionary<System.String, System.String> properties

    Dictionary of properties to set.

    System.Boolean checkoutIfRequired

    Check out the file if necessary to set properties.

    SetFilePropertiesAsync(File, IDictionary<String, String>, Boolean)

    Sets file properties using a dictionary.

    Declaration
    public static async Task SetFilePropertiesAsync(this File file, IDictionary<string, string> properties, bool checkoutIfRequired = true)
    Parameters
    File file

    Target file object.

    IDictionary<System.String, System.String> properties

    Dictionary of properties to set.

    System.Boolean checkoutIfRequired

    Check out the file if necessary to set properties.

    Returns
    Task

    UndoCheckOutFile(Web, String)

    Discard changes to a file

    Declaration
    public static void UndoCheckOutFile(this Web web, string serverRelativeUrl)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to dicard changes

    UndoCheckOutFileAsync(Web, String)

    Discard changes to a file

    Declaration
    public static async Task UndoCheckOutFileAsync(this Web web, string serverRelativeUrl)
    Parameters
    Web web

    The web to process

    System.String serverRelativeUrl

    The server relative URL of the file to dicard changes

    Returns
    Task

    UploadFile(Folder, String, Stream, Boolean)

    Uploads a file to the specified folder.

    Declaration
    public static File UploadFile(this Folder folder, string fileName, Stream stream, bool overwriteIfExists)
    Parameters
    Folder folder

    Folder to upload file to.

    System.String fileName

    Location of the file to be uploaded.

    Stream stream

    A stream object that represents the file.

    System.Boolean overwriteIfExists

    true (default) to overwite existing files

    Returns
    File

    The uploaded File, so that additional operations (such as setting properties) can be done.

    UploadFile(Folder, String, String, Boolean)

    Uploads a file to the specified folder.

    Declaration
    public static File UploadFile(this Folder folder, string fileName, string localFilePath, bool overwriteIfExists)
    Parameters
    Folder folder

    Folder to upload file to.

    System.String fileName

    Name of the file

    System.String localFilePath

    Location of the file to be uploaded.

    System.Boolean overwriteIfExists

    true (default) to overwite existing files

    Returns
    File

    The uploaded File, so that additional operations (such as setting properties) can be done.

    UploadFileAsync(Folder, String, Stream, Boolean)

    Uploads a file to the specified folder.

    Declaration
    public static async Task<File> UploadFileAsync(this Folder folder, string fileName, Stream stream, bool overwriteIfExists)
    Parameters
    Folder folder

    Folder to upload file to.

    System.String fileName

    Location of the file to be uploaded.

    Stream stream

    A stream object that represents the file.

    System.Boolean overwriteIfExists

    true (default) to overwite existing files

    Returns
    Task<File>

    The uploaded File, so that additional operations (such as setting properties) can be done.

    UploadFileAsync(Folder, String, String, Boolean)

    Uploads a file to the specified folder.

    Declaration
    public static async Task<File> UploadFileAsync(this Folder folder, string fileName, string localFilePath, bool overwriteIfExists)
    Parameters
    Folder folder

    Folder to upload file to.

    System.String fileName

    Name of the file

    System.String localFilePath

    Location of the file to be uploaded.

    System.Boolean overwriteIfExists

    true (default) to overwite existing files

    Returns
    Task<File>

    The uploaded File, so that additional operations (such as setting properties) can be done.

    VerifyIfUploadRequired(File, Stream)

    Used to compare the server file to the local file. This enables users with faster download speeds but slow upload speeds to evaluate if the server file should be overwritten.

    Declaration
    public static bool VerifyIfUploadRequired(this File serverFile, Stream localStream)
    Parameters
    File serverFile

    File located on the server.

    Stream localStream

    Stream to validate against.

    Returns
    System.Boolean

    VerifyIfUploadRequired(File, String)

    Used to compare the server file to the local file. This enables users with faster download speeds but slow upload speeds to evaluate if the server file should be overwritten.

    Declaration
    public static bool VerifyIfUploadRequired(this File serverFile, string localFile)
    Parameters
    File serverFile

    File located on the server.

    System.String localFile

    File to validate against.

    Returns
    System.Boolean

    VerifyIfUploadRequiredAsync(File, Stream)

    Used to compare the server file to the local file. This enables users with faster download speeds but slow upload speeds to evaluate if the server file should be overwritten.

    Declaration
    public static async Task<bool> VerifyIfUploadRequiredAsync(this File serverFile, Stream localStream)
    Parameters
    File serverFile

    File located on the server.

    Stream localStream

    Stream to validate against.

    Returns
    Task<System.Boolean>

    VerifyIfUploadRequiredAsync(File, String)

    Used to compare the server file to the local file. This enables users with faster download speeds but slow upload speeds to evaluate if the server file should be overwritten.

    Declaration
    public static async Task<bool> VerifyIfUploadRequiredAsync(this File serverFile, string localFile)
    Parameters
    File serverFile

    File located on the server.

    System.String localFile

    File to validate against.

    Returns
    Task<System.Boolean>

    VerifyIfUploadRequiredImplementation(File, Stream)

    Used to compare the server file to the local file. This enables users with faster download speeds but slow upload speeds to evaluate if the server file should be overwritten.

    Declaration
    public static async Task<bool> VerifyIfUploadRequiredImplementation(this File serverFile, Stream localStream)
    Parameters
    File serverFile

    File located on the server.

    Stream localStream

    Stream to validate against.

    Returns
    Task<System.Boolean>

    Back to top PnP Framework
    Generated by DocFX with Material UI
    spacer