Interface IFileManager
Do not implement. This interface is meant for reference and unit test purposes only. There is no guarantee that this interface will not change.
Namespace: DotNetNuke.Services.FileSystem
Assembly: DotNetNuke.dll
Syntax
public interface IFileManager
Properties
| Improve this Doc View SourceContentTypes
Gets the system defined content types.
Declaration
IDictionary<string, string> ContentTypes { get; }
Property Value
Type | Description |
---|---|
IDictionary<System.String, System.String> |
WhiteList
Gets current user's file upload extension whitelist.
Declaration
FileExtensionWhitelist WhiteList { get; }
Property Value
Type | Description |
---|---|
FileExtensionWhitelist |
Methods
| Improve this Doc View SourceAddFile(IFolderInfo, String, Stream, Boolean, Boolean, Boolean, String, Int32)
Adds a file to the specified folder.
Declaration
IFileInfo AddFile(IFolderInfo folder, string fileName, Stream fileContent, bool overwrite, bool checkPermissions, bool ignoreWhiteList, string contentType, int createdByUserID)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to add the file. |
System.String | fileName | The name of the file. |
Stream | fileContent | The content of the file. |
System.Boolean | overwrite | Indicates if the file has to be over-written if it exists. |
System.Boolean | checkPermissions | Indicates if permissions have to be met. |
System.Boolean | ignoreWhiteList | Indicates whether the whitelist should be ignored. |
System.String | contentType | The content type of the file. |
System.Int32 | createdByUserID | ID of the user that creates the file. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as specified by the parameters. |
AddFile(IFolderInfo, String, Stream, Boolean, Boolean, String, Int32)
Adds a file to the specified folder.
Declaration
IFileInfo AddFile(IFolderInfo folder, string fileName, Stream fileContent, bool overwrite, bool checkPermissions, string contentType, int createdByUserID)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to add the file. |
System.String | fileName | The name of the file. |
Stream | fileContent | The content of the file. |
System.Boolean | overwrite | Indicates if the file has to be over-written if it exists. |
System.Boolean | checkPermissions | Indicates if permissions have to be met. |
System.String | contentType | The content type of the file. |
System.Int32 | createdByUserID | ID of the user that creates the file. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as specified by the parameters. |
AddFile(IFolderInfo, String, Stream, Boolean, Boolean, String)
Adds a file to the specified folder.
Declaration
IFileInfo AddFile(IFolderInfo folder, string fileName, Stream fileContent, bool overwrite, bool checkPermissions, string contentType)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to add the file. |
System.String | fileName | The name of the file. |
Stream | fileContent | The content of the file. |
System.Boolean | overwrite | Indicates if the file has to be over-written if it exists. |
System.Boolean | checkPermissions | Indicates if permissions have to be met. |
System.String | contentType | The content type of the file. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as specified by the parameters. |
AddFile(IFolderInfo, String, Stream, Boolean)
Adds a file to the specified folder.
Declaration
IFileInfo AddFile(IFolderInfo folder, string fileName, Stream fileContent, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to add the file. |
System.String | fileName | The name of the file. |
Stream | fileContent | The content of the file. |
System.Boolean | overwrite | Indicates if the file has to be over-written if it exits. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as specified by the parameters. |
AddFile(IFolderInfo, String, Stream)
Adds a file to the specified folder.
Declaration
IFileInfo AddFile(IFolderInfo folder, string fileName, Stream fileContent)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to add the file. |
System.String | fileName | The name of the file. |
Stream | fileContent | The content of the file. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as specified by the parameters. |
CopyFile(IFileInfo, IFolderInfo)
Copies the specified file into the specified folder.
Declaration
IFileInfo CopyFile(IFileInfo file, IFolderInfo destinationFolder)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to copy. |
IFolderInfo | destinationFolder | The folder where to copy the file to. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo with the information of the copied file. |
DeleteFile(IFileInfo)
Deletes the specified file.
Declaration
void DeleteFile(IFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to delete. |
DeleteFiles(IEnumerable<IFileInfo>)
Deletes the specified files.
Declaration
void DeleteFiles(IEnumerable<IFileInfo> files)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IFileInfo> | files | The files to delete. |
FileExists(IFolderInfo, String, Boolean)
Checks the existence of the specified file in the specified folder.
Declaration
bool FileExists(IFolderInfo folder, string fileName, bool retrieveUnpublishedFiles)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to check the existence of the file. |
System.String | fileName | The file name to check the existence of. |
System.Boolean | retrieveUnpublishedFiles | Indicates if the file is retrieved from All files or from Published files. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether the file exists or not in the specified folder. |
FileExists(IFolderInfo, String)
Checks the existence of the specified file in the specified folder.
Declaration
bool FileExists(IFolderInfo folder, string fileName)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where to check the existence of the file. |
System.String | fileName | The file name to check the existence of. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether the file exists or not in the specified folder. |
GetContentType(String)
Gets the Content Type for the specified file extension.
Declaration
string GetContentType(string extension)
Parameters
Type | Name | Description |
---|---|---|
System.String | extension | The file extension. |
Returns
Type | Description |
---|---|
System.String | The Content Type for the specified extension. |
GetFile(IFolderInfo, String, Boolean)
Gets the file metadata for the specified file.
Declaration
IFileInfo GetFile(IFolderInfo folder, string fileName, bool retrieveUnpublishedFiles)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where the file is stored. |
System.String | fileName | The name of the file. |
System.Boolean | retrieveUnpublishedFiles | Indicates if the file is retrieved from All files or from Published files. |
Returns
Type | Description |
---|---|
IFileInfo | The IFileInfo object with the metadata of the specified file. |
GetFile(IFolderInfo, String)
Gets the file metadata for the specified file.
Declaration
IFileInfo GetFile(IFolderInfo folder, string fileName)
Parameters
Type | Name | Description |
---|---|---|
IFolderInfo | folder | The folder where the file is stored. |
System.String | fileName | The name of the file. |
Returns
Type | Description |
---|---|
IFileInfo | The IFileInfo object with the metadata of the specified file. |
GetFile(Int32, Boolean)
Gets the file metadata for the specified file.
Declaration
IFileInfo GetFile(int fileID, bool retrieveUnpublishedFiles)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fileID | The file identifier. |
System.Boolean | retrieveUnpublishedFiles | Indicates if the file is retrieved from All files or from Published files. |
Returns
Type | Description |
---|---|
IFileInfo | The IFileInfo object with the metadata of the specified file. |
GetFile(Int32, String, Boolean)
Gets the file metadata for the specified file.
Declaration
IFileInfo GetFile(int portalId, string relativePath, bool retrieveUnpublishedFiles)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | portalId | The portal ID or Null.NullInteger for the Host. |
System.String | relativePath | Relative path to the file. |
System.Boolean | retrieveUnpublishedFiles | Indicates if the file is retrieved from All files or from Published files. |
Returns
Type | Description |
---|---|
IFileInfo | The IFileInfo object with the metadata of the specified file. |
Remarks
Host and portal settings commonly return a relative path to a file. This method uses that relative path to fetch file metadata.
GetFile(Int32, String)
Gets the file metadata for the specified file.
Declaration
IFileInfo GetFile(int portalId, string relativePath)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | portalId | The portal ID or Null.NullInteger for the Host. |
System.String | relativePath | Relative path to the file. |
Returns
Type | Description |
---|---|
IFileInfo | The IFileInfo object with the metadata of the specified file. |
Remarks
Host and portal settings commonly return a relative path to a file. This method uses that relative path to fetch file metadata.
GetFile(Int32)
Gets the file metadata for the specified file.
Declaration
IFileInfo GetFile(int fileID)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fileID | The file identifier. |
Returns
Type | Description |
---|---|
IFileInfo | The IFileInfo object with the metadata of the specified file. |
GetFileContent(IFileInfo)
Gets the content of the specified file.
Declaration
Stream GetFileContent(IFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to get the content from. |
Returns
Type | Description |
---|---|
Stream | A stream with the content of the file. |
GetSeekableStream(Stream)
Gets a seekable Stream based on the specified non-seekable Stream.
Declaration
Stream GetSeekableStream(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | A non-seekable Stream. |
Returns
Type | Description |
---|---|
Stream | A seekable Stream. |
GetUrl(IFileInfo)
Gets the direct Url to the file.
Declaration
string GetUrl(IFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to get the Url. |
Returns
Type | Description |
---|---|
System.String | The direct Url to the file. |
IsImageFile(IFileInfo)
Gets a flag that dertermines if the file is an Image.
Declaration
bool IsImageFile(IFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to test. |
Returns
Type | Description |
---|---|
System.Boolean | The flag as a boolean value. |
MoveFile(IFileInfo, IFolderInfo)
Moves the specified file into the specified folder.
Declaration
IFileInfo MoveFile(IFileInfo file, IFolderInfo destinationFolder)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to move. |
IFolderInfo | destinationFolder | The folder where to move the file to. |
Returns
Type | Description |
---|---|
IFileInfo | An IFileInfo with the information of the moved file. |
RenameFile(IFileInfo, String)
Renames the specified file.
Declaration
IFileInfo RenameFile(IFileInfo file, string newFileName)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to rename. |
System.String | newFileName | The new filename to assign to the file. |
Returns
Type | Description |
---|---|
IFileInfo | An IFileInfo with the information of the renamed file. |
SetAttributes(IFileInfo, FileAttributes)
Sets the specified FileAttributes of the file.
Declaration
void SetAttributes(IFileInfo file, FileAttributes fileAttributes)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file. |
FileAttributes | fileAttributes | The file attributes to add. |
UnzipFile(IFileInfo, IFolderInfo, IList<String>)
Extracts the files and folders contained in the specified zip file to the specified folder.
Declaration
int UnzipFile(IFileInfo file, IFolderInfo destinationFolder, IList<string> invalidFiles)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to unzip. |
IFolderInfo | destinationFolder | The folder to unzip to. |
IList<System.String> | invalidFiles | Files which can't exact. |
Returns
Type | Description |
---|---|
System.Int32 | Total files count in the zip file. |
UnzipFile(IFileInfo, IFolderInfo)
Extracts the files and folders contained in the specified zip file to the specified folder.
Declaration
void UnzipFile(IFileInfo file, IFolderInfo destinationFolder)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to unzip. |
IFolderInfo | destinationFolder | The folder to unzip to. |
UnzipFile(IFileInfo)
Extracts the files and folders contained in the specified zip file to the folder where the file belongs.
Declaration
void UnzipFile(IFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to unzip. |
UpdateFile(IFileInfo, Stream)
Regenerates the hash and updates the metadata of the specified file.
Declaration
IFileInfo UpdateFile(IFileInfo file, Stream fileContent)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to update. |
Stream | fileContent | Stream used to regenerate the hash. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as the updated file. |
UpdateFile(IFileInfo)
Updates the metadata of the specified file.
Declaration
IFileInfo UpdateFile(IFileInfo file)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to update. |
Returns
Type | Description |
---|---|
IFileInfo | A IFileInfo as the updated file. |
WriteFile(IFileInfo, Stream)
Writes the content of the specified file into the specified stream.
Declaration
void WriteFile(IFileInfo file, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to write into the stream. |
Stream | stream | The stream to write to. |
WriteFileToResponse(IFileInfo, ContentDisposition)
Downloads the specified file.
Declaration
void WriteFileToResponse(IFileInfo file, ContentDisposition contentDisposition)
Parameters
Type | Name | Description |
---|---|---|
IFileInfo | file | The file to download. |
ContentDisposition | contentDisposition | Indicates how to display the document once downloaded. |