Interface IFileService
Defines the File Service, which is an easy access to operations involving IFile objects like Scripts, Stylesheets and Templates
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IFileService : IServiceMethods
View SourceCreatePartialView(IPartialView, String, Nullable<Int32>)
Declaration
Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int? userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| IPartialView | partialView | |
| System.String | snippetName | |
| System.Nullable<System.Int32> | userId | 
Returns
| Type | Description | 
|---|---|
| Attempt<IPartialView> | 
CreatePartialViewFolder(String)
Declaration
void CreatePartialViewFolder(string folderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | folderPath | 
CreateScriptFolder(String)
Creates a folder for scripts
Declaration
void CreateScriptFolder(string folderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | folderPath | 
CreateStyleSheetFolder(String)
Creates a folder for style sheets
Declaration
void CreateStyleSheetFolder(string folderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | folderPath | 
CreateTemplateForContentType(String, String, Int32)
Creates a template for a content type
Declaration
Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | contentTypeAlias | |
| System.String | contentTypeName | |
| System.Int32 | userId | 
Returns
| Type | Description | 
|---|---|
| Attempt<OperationResult<OperationResultType, ITemplate>> | The template created | 
CreateTemplateWithIdentity(String, String, String, ITemplate, Int32)
Declaration
ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | |
| System.String | alias | |
| System.String | content | |
| ITemplate | masterTemplate | |
| System.Int32 | userId | 
Returns
| Type | Description | 
|---|---|
| ITemplate | 
DeletePartialView(String, Nullable<Int32>)
Declaration
bool DeletePartialView(string path, int? userId = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | |
| System.Nullable<System.Int32> | userId | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
DeletePartialViewFolder(String)
Declaration
void DeletePartialViewFolder(string folderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | folderPath | 
DeleteScript(String, Nullable<Int32>)
Deletes a script by its name
Declaration
void DeleteScript(string path, int? userId = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | Name incl. extension of the Script to delete | 
| System.Nullable<System.Int32> | userId | Optional id of the user deleting the script | 
DeleteScriptFolder(String)
Deletes a folder for scripts
Declaration
void DeleteScriptFolder(string folderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | folderPath | 
DeleteStylesheet(String, Nullable<Int32>)
Deletes a stylesheet by its name
Declaration
void DeleteStylesheet(string path, int? userId = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | Name incl. extension of the Stylesheet to delete | 
| System.Nullable<System.Int32> | userId | Optional id of the user deleting the stylesheet | 
DeleteStyleSheetFolder(String)
Deletes a folder for style sheets
Declaration
void DeleteStyleSheetFolder(string folderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | folderPath | 
DeleteTemplate(String, Int32)
Deletes a template by its alias
Declaration
void DeleteTemplate(string alias, int userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | alias | Alias of the ITemplate to delete | 
| System.Int32 | userId | Optional id of the user deleting the template | 
GetPartialView(String)
Declaration
IPartialView GetPartialView(string path)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | 
Returns
| Type | Description | 
|---|---|
| IPartialView | 
GetPartialViewFileContentStream(String)
Gets the content of a partial view as a stream.
Declaration
Stream GetPartialViewFileContentStream(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the partial view. | 
Returns
| Type | Description | 
|---|---|
| Stream | The content of the partial view. | 
GetPartialViewFileSize(String)
Gets the size of a partial view.
Declaration
long GetPartialViewFileSize(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the partial view. | 
Returns
| Type | Description | 
|---|---|
| System.Int64 | The size of the partial view. | 
GetPartialViews(String[])
Gets a list of all IPartialView objects
Declaration
IEnumerable<IPartialView> GetPartialViews(params string[] names)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | names | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<IPartialView> | An enumerable list of IPartialView objects | 
GetScript(String)
Gets a IScript object by its name
Declaration
IScript GetScript(string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name of the script incl. extension | 
Returns
| Type | Description | 
|---|---|
| IScript | A IScript object | 
GetScriptFileContentStream(String)
Gets the content of a script file as a stream.
Declaration
Stream GetScriptFileContentStream(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the script. | 
Returns
| Type | Description | 
|---|---|
| Stream | The content of the script file. | 
GetScriptFileSize(String)
Gets the size of a script file.
Declaration
long GetScriptFileSize(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the script file. | 
Returns
| Type | Description | 
|---|---|
| System.Int64 | The size of the script file. | 
GetScripts(String[])
Gets a list of all IScript objects
Declaration
IEnumerable<IScript> GetScripts(params string[] names)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | names | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<IScript> | An enumerable list of IScript objects | 
GetStylesheet(String)
Gets a IStylesheet object by its name
Declaration
IStylesheet GetStylesheet(string path)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | Path of the stylesheet incl. extension | 
Returns
| Type | Description | 
|---|---|
| IStylesheet | A IStylesheet object | 
GetStylesheetFileContentStream(String)
Gets the content of a stylesheet as a stream.
Declaration
Stream GetStylesheetFileContentStream(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the stylesheet. | 
Returns
| Type | Description | 
|---|---|
| Stream | The content of the stylesheet. | 
GetStylesheetFileSize(String)
Gets the size of a stylesheet.
Declaration
long GetStylesheetFileSize(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the stylesheet. | 
Returns
| Type | Description | 
|---|---|
| System.Int64 | The size of the stylesheet. | 
GetStylesheets(String[])
Gets a list of all IStylesheet objects
Declaration
IEnumerable<IStylesheet> GetStylesheets(params string[] paths)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | paths | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<IStylesheet> | An enumerable list of IStylesheet objects | 
GetTemplate(Guid)
Gets a ITemplate object by its guid identifier.
Declaration
ITemplate GetTemplate(Guid id)Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | id | The guid identifier of the template. | 
Returns
| Type | Description | 
|---|---|
| ITemplate | The ITemplate object matching the identifier, or null. | 
GetTemplate(Int32)
Gets a ITemplate object by its identifier.
Declaration
ITemplate GetTemplate(int id)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | id | The identifier of the template. | 
Returns
| Type | Description | 
|---|---|
| ITemplate | The ITemplate object matching the identifier, or null. | 
GetTemplate(String)
Gets a ITemplate object by its alias.
Declaration
ITemplate GetTemplate(string alias)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | alias | The alias of the template. | 
Returns
| Type | Description | 
|---|---|
| ITemplate | The ITemplate object matching the alias, or null. | 
GetTemplateDescendants(Int32)
Gets the template descendants
Declaration
IEnumerable<ITemplate> GetTemplateDescendants(int masterTemplateId)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | masterTemplateId | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<ITemplate> | 
GetTemplateFileContentStream(String)
Gets the content of a template as a stream.
Declaration
Stream GetTemplateFileContentStream(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the template. | 
Returns
| Type | Description | 
|---|---|
| Stream | The content of the template. | 
GetTemplateFileSize(String)
Gets the size of a template.
Declaration
long GetTemplateFileSize(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the template. | 
Returns
| Type | Description | 
|---|---|
| System.Int64 | The size of the template. | 
GetTemplates(Int32)
Gets a list of all ITemplate objects
Declaration
IEnumerable<ITemplate> GetTemplates(int masterTemplateId)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | masterTemplateId | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<ITemplate> | An enumerable list of ITemplate objects | 
GetTemplates(String[])
Gets a list of all ITemplate objects
Declaration
IEnumerable<ITemplate> GetTemplates(params string[] aliases)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | aliases | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<ITemplate> | An enumerable list of ITemplate objects | 
SavePartialView(IPartialView, Nullable<Int32>)
Declaration
Attempt<IPartialView> SavePartialView(IPartialView partialView, int? userId = null)Parameters
| Type | Name | Description | 
|---|---|---|
| IPartialView | partialView | |
| System.Nullable<System.Int32> | userId | 
Returns
| Type | Description | 
|---|---|
| Attempt<IPartialView> | 
SaveScript(IScript, Nullable<Int32>)
Saves a Script
Declaration
void SaveScript(IScript script, int? userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| IScript | script | IScript to save | 
| System.Nullable<System.Int32> | userId | Optional id of the user saving the script | 
SaveStylesheet(IStylesheet, Nullable<Int32>)
Saves a IStylesheet
Declaration
void SaveStylesheet(IStylesheet stylesheet, int? userId = null)Parameters
| Type | Name | Description | 
|---|---|---|
| IStylesheet | stylesheet | IStylesheet to save | 
| System.Nullable<System.Int32> | userId | Optional id of the user saving the stylesheet | 
SaveTemplate(IEnumerable<ITemplate>, Int32)
Saves a collection of Template objects
Declaration
void SaveTemplate(IEnumerable<ITemplate> templates, int userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| IEnumerable<ITemplate> | templates | List of Template to save | 
| System.Int32 | userId | Optional id of the user | 
SaveTemplate(ITemplate, Int32)
Saves a ITemplate
Declaration
void SaveTemplate(ITemplate template, int userId = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| ITemplate | template | ITemplate to save | 
| System.Int32 | userId | Optional id of the user saving the template | 
SetPartialViewFileContent(String, Stream)
Sets the content of a partial view.
Declaration
void SetPartialViewFileContent(string filepath, Stream content)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the partial view. | 
| Stream | content | The content of the partial view. | 
SetScriptFileContent(String, Stream)
Sets the content of a script file.
Declaration
void SetScriptFileContent(string filepath, Stream content)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the script. | 
| Stream | content | The content of the script file. | 
SetStylesheetFileContent(String, Stream)
Sets the content of a stylesheet.
Declaration
void SetStylesheetFileContent(string filepath, Stream content)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the stylesheet. | 
| Stream | content | The content of the stylesheet. | 
SetTemplateFileContent(String, Stream)
Sets the content of a template.
Declaration
void SetTemplateFileContent(string filepath, Stream content)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the template. | 
| Stream | content | The content of the template. |