C# Класс Microsoft.SharePoint.Client.FileFolderExtensions

Показать файл Открыть проект

Открытые методы

Метод Описание
ApproveFile ( this web, string serverRelativeUrl, string comment ) : void

Approves a file

CheckInFile ( this web, string serverRelativeUrl, CheckinType checkinType, string comment ) : void

Checks in a file

CheckOutFile ( this web, string serverRelativeUrl ) : void

Checks out a file

ConvertFolderToDocumentSet ( this list, Folder folder ) : Folder

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

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

ConvertFolderToDocumentSet ( this list, string folderName ) : Folder

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

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

CreateDocumentSet ( this folder, string documentSetName, ContentTypeId contentTypeId ) : Folder

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

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

CreateFolder ( this web, string folderName ) : Folder

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.

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

DoesFolderExists ( this web, string serverRelativeFolderUrl ) : bool

Checks if a specific folder exists

EnsureFolder ( this web, Folder parentFolder, string folderPath ) : Folder

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

EnsureFolder ( this web, string folderName ) : Folder

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.

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

EnsureFolderPath ( this web, string webRelativeUrl ) : Folder

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

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 ( this web, string match ) : List

Finds files in the web. Can be slow.

FolderExists ( this web, string folderName ) : bool

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

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

GetFile ( this folder, string fileName ) : File

Gets a file in a document library.

GetFileAsString ( this web, string serverRelativeUrl ) : string

Returns a file as string

PublishFile ( this web, string serverRelativeUrl, string comment ) : void

Publishes a file existing on a server url

ResolveSubFolder ( this folder, string folderName ) : Folder

Gets a folder with a given name in a given Microsoft.SharePoint.Client.Folder

SaveFileToLocal ( this web, string serverRelativeUrl, string localPath, string localFileName = null, bool>.Func fileExistsCallBack = null ) : void

Saves a remote file to a local folder

UploadFile ( this folder, string fileName, string localFilePath, bool overwriteIfExists ) : File

Uploads a file to the specified folder.

UploadFileWebDav ( this folder, string fileName, string localFilePath, bool overwriteIfExists ) : File

Uploads a file to the specified folder by saving the binary directly (via webdav).

VerifyIfUploadRequired ( this serverFile, Stream localStream ) : bool

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.

VerifyIfUploadRequired ( this serverFile, string localFile ) : bool

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.

Приватные методы

Метод Описание
ConvertFolderToDocumentSetImplementation ( this list, Folder folder ) : Folder

Internal implementation of the Folder conversion to Document set

CopyStream ( Stream source, Stream destination ) : void
CreateFolderImplementation ( FolderCollection folderCollection, string folderName, Folder parentFolder = null ) : Folder
EnsureFolderImplementation ( FolderCollection folderCollection, string folderName, Folder parentFolder = null ) : Folder
FolderExistsImplementation ( FolderCollection folderCollection, string folderName ) : bool
ParseFiles ( Folder folder, string match, ClientContext context, List &foundFiles ) : void
PublishFileToLevel ( this file, FileLevel level ) : void
SetFileProperties ( this file, string>.IDictionary properties, bool checkoutIfRequired = true ) : void
UploadFile ( this folder, string fileName, Stream stream, bool overwriteIfExists ) : File
UploadFileWebDav ( this folder, string fileName, Stream stream, bool overwriteIfExists ) : File
WildcardToRegex ( string pattern ) : string

Описание методов

ApproveFile() публичный статический Метод

Approves a file
public static ApproveFile ( this web, string serverRelativeUrl, string comment ) : void
web this The web to process
serverRelativeUrl string The server relative url of the file to approve
comment string Message to be recorded with the approval
Результат void

CheckInFile() публичный статический Метод

Checks in a file
public static CheckInFile ( this web, string serverRelativeUrl, CheckinType checkinType, string comment ) : void
web this The web to process
serverRelativeUrl string The server relative url of the file to checkin
checkinType CheckinType The type of the checkin
comment string Message to be recorded with the approval
Результат void

CheckOutFile() публичный статический Метод

Checks out a file
public static CheckOutFile ( this web, string serverRelativeUrl ) : void
web this The web to process
serverRelativeUrl string The server relative url of the file to checkout
Результат void

ConvertFolderToDocumentSet() публичный статический Метод

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

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

public static ConvertFolderToDocumentSet ( this list, Folder folder ) : Folder
list this List in which the folder exists
folder Folder Folder to convert
Результат Folder

ConvertFolderToDocumentSet() публичный статический Метод

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

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

public static ConvertFolderToDocumentSet ( this list, string folderName ) : Folder
list this List in which the folder exists
folderName string Folder name to convert
Результат Folder

CreateDocumentSet() публичный статический Метод

Creates a new document set as a child of an existing folder, with the specified content type ID.
var setContentType = list.BestMatchContentTypeId(BuiltInContentTypeId.DocumentSet); var set1 = list.RootFolder.CreateDocumentSet("Set 1", setContentType);
public static CreateDocumentSet ( this folder, string documentSetName, ContentTypeId contentTypeId ) : Folder
folder this
documentSetName string
contentTypeId ContentTypeId Content type of the document set
Результат Folder

CreateFolder() публичный статический Метод

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.

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

public static CreateFolder ( this web, string folderName ) : Folder
web this Web to check for the named folder
folderName string Folder name to retrieve or create
Результат Folder

DoesFolderExists() публичный статический Метод

Checks if a specific folder exists
public static DoesFolderExists ( this web, string serverRelativeFolderUrl ) : bool
web this The web to process
serverRelativeFolderUrl string Folder to check
Результат bool

EnsureFolder() публичный статический Метод

Ensure that the folder structure is created. This also ensures hierarchy of folders.
public static EnsureFolder ( this web, Folder parentFolder, string folderPath ) : Folder
web this Web to be processed - can be root web or sub site
parentFolder Folder Parent folder
folderPath string Folder path
Результат Folder

EnsureFolder() публичный статический Метод

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.

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

public static EnsureFolder ( this web, string folderName ) : Folder
web this Web to check for the named folder
folderName string Folder name to retrieve or create
Результат Folder

EnsureFolderPath() публичный статический Метод

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

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.

public static EnsureFolderPath ( this web, string webRelativeUrl ) : Folder
web this Web to check for the specified folder
webRelativeUrl string Path to the folder, relative to the web site
Результат Folder

FindFiles() публичный статический Метод

Finds files in the web. Can be slow.
public static FindFiles ( this web, string match ) : List
web this The web to process
match string a wildcard pattern to match
Результат List

FolderExists() публичный статический Метод

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

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

public static FolderExists ( this web, string folderName ) : bool
web this Web to check for the named folder
folderName string Folder name to retrieve
Результат bool

GetFile() публичный статический Метод

Gets a file in a document library.
public static GetFile ( this folder, string fileName ) : File
folder this Folder containing the target file.
fileName string File name.
Результат System.IO.File

GetFileAsString() публичный статический Метод

Returns a file as string
public static GetFileAsString ( this web, string serverRelativeUrl ) : string
web this The Web to process
serverRelativeUrl string The server relative url to the file
Результат string

PublishFile() публичный статический Метод

Publishes a file existing on a server url
public static PublishFile ( this web, string serverRelativeUrl, string comment ) : void
web this The web to process
serverRelativeUrl string the server relative url of the file to publish
comment string Comment recorded with the publish action
Результат void

ResolveSubFolder() публичный статический Метод

Gets a folder with a given name in a given Microsoft.SharePoint.Client.Folder
public static ResolveSubFolder ( this folder, string folderName ) : Folder
folder this in which to search for
folderName string Name of the folder to search for
Результат Folder

SaveFileToLocal() публичный статический Метод

Saves a remote file to a local folder
public static SaveFileToLocal ( this web, string serverRelativeUrl, string localPath, string localFileName = null, bool>.Func fileExistsCallBack = null ) : void
web this The Web to process
serverRelativeUrl string The server relative url to the file
localPath string The local folder
localFileName string The local filename. If null the filename of the file on the server will be used
fileExistsCallBack bool>.Func 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.
Результат void

UploadFile() публичный статический Метод

Uploads a file to the specified folder.
public static UploadFile ( this folder, string fileName, string localFilePath, bool overwriteIfExists ) : File
folder this Folder to upload file to.
fileName string
localFilePath string Location of the file to be uploaded.
overwriteIfExists bool true (default) to overwite existing files
Результат System.IO.File

UploadFileWebDav() публичный статический Метод

Uploads a file to the specified folder by saving the binary directly (via webdav).
public static UploadFileWebDav ( this folder, string fileName, string localFilePath, bool overwriteIfExists ) : File
folder this Folder to upload file to.
fileName string
localFilePath string Location of the file to be uploaded.
overwriteIfExists bool true (default) to overwite existing files
Результат System.IO.File

VerifyIfUploadRequired() публичный статический Метод

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.
public static VerifyIfUploadRequired ( this serverFile, Stream localStream ) : bool
serverFile this File located on the server.
localStream Stream Stream to validate against.
Результат bool

VerifyIfUploadRequired() публичный статический Метод

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.
public static VerifyIfUploadRequired ( this serverFile, string localFile ) : bool
serverFile this File located on the server.
localFile string File to validate against.
Результат bool