Search Results for

    Show / Hide Table of Contents
    View Source

    Class FileService

    Represents the File Service, which is an easy access to operations involving IFile objects like Scripts, Stylesheets and Templates

    Inheritance
    object
    RepositoryService
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class FileService : RepositoryService, IFileService, IService

    Constructors

    View Source

    FileService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IStylesheetRepository, IScriptRepository, IPartialViewRepository, IAuditRepository, IHostingEnvironment, ITemplateService, ITemplateRepository, IUserIdKeyResolver, IShortStringHelper, IOptions<GlobalSettings>)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")]
    public FileService(ICoreScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IStylesheetRepository stylesheetRepository, IScriptRepository scriptRepository, IPartialViewRepository partialViewRepository, IAuditRepository auditRepository, IHostingEnvironment hostingEnvironment, ITemplateService templateService, ITemplateRepository templateRepository, IUserIdKeyResolver userIdKeyResolver, IShortStringHelper shortStringHelper, IOptions<GlobalSettings> globalSettings)
    Parameters
    Type Name Description
    ICoreScopeProvider uowProvider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IStylesheetRepository stylesheetRepository
    IScriptRepository scriptRepository
    IPartialViewRepository partialViewRepository
    IAuditRepository auditRepository
    IHostingEnvironment hostingEnvironment
    ITemplateService templateService
    ITemplateRepository templateRepository
    IUserIdKeyResolver userIdKeyResolver
    IShortStringHelper shortStringHelper
    IOptions<GlobalSettings> globalSettings
    View Source

    FileService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IStylesheetRepository, IScriptRepository, IPartialViewRepository, IAuditService, IHostingEnvironment, ITemplateService, ITemplateRepository, IUserIdKeyResolver)

    Declaration
    public FileService(ICoreScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IStylesheetRepository stylesheetRepository, IScriptRepository scriptRepository, IPartialViewRepository partialViewRepository, IAuditService auditService, IHostingEnvironment hostingEnvironment, ITemplateService templateService, ITemplateRepository templateRepository, IUserIdKeyResolver userIdKeyResolver)
    Parameters
    Type Name Description
    ICoreScopeProvider uowProvider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IStylesheetRepository stylesheetRepository
    IScriptRepository scriptRepository
    IPartialViewRepository partialViewRepository
    IAuditService auditService
    IHostingEnvironment hostingEnvironment
    ITemplateService templateService
    ITemplateRepository templateRepository
    IUserIdKeyResolver userIdKeyResolver
    View Source

    FileService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IStylesheetRepository, IScriptRepository, IPartialViewRepository, IAuditService, IAuditRepository, IHostingEnvironment, ITemplateService, ITemplateRepository, IUserIdKeyResolver, IShortStringHelper, IOptions<GlobalSettings>)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")]
    public FileService(ICoreScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IStylesheetRepository stylesheetRepository, IScriptRepository scriptRepository, IPartialViewRepository partialViewRepository, IAuditService auditService, IAuditRepository auditRepository, IHostingEnvironment hostingEnvironment, ITemplateService templateService, ITemplateRepository templateRepository, IUserIdKeyResolver userIdKeyResolver, IShortStringHelper shortStringHelper, IOptions<GlobalSettings> globalSettings)
    Parameters
    Type Name Description
    ICoreScopeProvider uowProvider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IStylesheetRepository stylesheetRepository
    IScriptRepository scriptRepository
    IPartialViewRepository partialViewRepository
    IAuditService auditService
    IAuditRepository auditRepository
    IHostingEnvironment hostingEnvironment
    ITemplateService templateService
    ITemplateRepository templateRepository
    IUserIdKeyResolver userIdKeyResolver
    IShortStringHelper shortStringHelper
    IOptions<GlobalSettings> globalSettings

    Methods

    View Source

    CreatePartialView(IPartialView, string?, int?)

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public Attempt<IPartialView?> CreatePartialView(IPartialView partialView, string? snippetName = null, int? userId = -1)
    Parameters
    Type Name Description
    IPartialView partialView
    string snippetName
    int? userId
    Returns
    Type Description
    Attempt<IPartialView>
    View Source

    CreatePartialViewFolder(string)

    Declaration
    [Obsolete("Please use IPartialViewFolderService for partial view folder operations - will be removed in Umbraco 15")]
    public void CreatePartialViewFolder(string folderPath)
    Parameters
    Type Name Description
    string folderPath
    View Source

    CreateScriptFolder(string)

    Creates a folder for scripts

    Declaration
    [Obsolete("Please use IScriptFolderService for script folder operations - will be removed in Umbraco 15")]
    public void CreateScriptFolder(string folderPath)
    Parameters
    Type Name Description
    string folderPath
    View Source

    CreateStyleSheetFolder(string)

    Creates a folder for style sheets

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public void CreateStyleSheetFolder(string folderPath)
    Parameters
    Type Name Description
    string folderPath
    View Source

    CreateTemplateForContentType(string, string?, int)

    Creates a template for a content type

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public Attempt<OperationResult<OperationResultType, ITemplate>?> CreateTemplateForContentType(string contentTypeAlias, string? contentTypeName, int userId = -1)
    Parameters
    Type Name Description
    string contentTypeAlias
    string contentTypeName
    int userId
    Returns
    Type Description
    Attempt<OperationResult<OperationResultType, ITemplate>>

    The template created

    View Source

    CreateTemplateWithIdentity(string?, string?, string?, ITemplate?, int)

    Create a new template, setting the content if a view exists in the filesystem

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public ITemplate CreateTemplateWithIdentity(string? name, string? alias, string? content, ITemplate? masterTemplate = null, int userId = -1)
    Parameters
    Type Name Description
    string name
    string alias
    string content
    ITemplate masterTemplate
    int userId
    Returns
    Type Description
    ITemplate
    View Source

    DeletePartialView(string, int?)

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public bool DeletePartialView(string path, int? userId = null)
    Parameters
    Type Name Description
    string path
    int? userId
    Returns
    Type Description
    bool
    View Source

    DeletePartialViewFolder(string)

    Declaration
    [Obsolete("Please use IPartialViewFolderService for partial view folder operations - will be removed in Umbraco 15")]
    public void DeletePartialViewFolder(string folderPath)
    Parameters
    Type Name Description
    string folderPath
    View Source

    DeleteScript(string, int?)

    Deletes a script by its name

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public void DeleteScript(string path, int? userId = null)
    Parameters
    Type Name Description
    string path

    Name incl. extension of the Script to delete

    int? userId

    Optional id of the user deleting the script

    View Source

    DeleteScriptFolder(string)

    Deletes a folder for scripts

    Declaration
    [Obsolete("Please use IScriptFolderService for script folder operations - will be removed in Umbraco 15")]
    public void DeleteScriptFolder(string folderPath)
    Parameters
    Type Name Description
    string folderPath
    View Source

    DeleteStyleSheetFolder(string)

    Deletes a folder for style sheets

    Declaration
    [Obsolete("Please use IStylesheetFolderService for stylesheet folder operations - will be removed in Umbraco 15")]
    public void DeleteStyleSheetFolder(string folderPath)
    Parameters
    Type Name Description
    string folderPath
    View Source

    DeleteStylesheet(string, int?)

    Deletes a stylesheet by its name

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public void DeleteStylesheet(string path, int? userId)
    Parameters
    Type Name Description
    string path

    Name incl. extension of the Stylesheet to delete

    int? userId

    Optional id of the user deleting the stylesheet

    View Source

    DeleteTemplate(string, int)

    Deletes a template by its alias

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public void DeleteTemplate(string alias, int userId = -1)
    Parameters
    Type Name Description
    string alias

    Alias of the ITemplate to delete

    int userId
    View Source

    GetPartialView(string)

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public IPartialView? GetPartialView(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    IPartialView
    View Source

    GetPartialViewFileContentStream(string)

    Gets the content of a partial view as a stream.

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public Stream GetPartialViewFileContentStream(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the partial view.

    Returns
    Type Description
    Stream

    The content of the partial view.

    View Source

    GetPartialViewFileSize(string)

    Gets the size of a partial view.

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public long GetPartialViewFileSize(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the partial view.

    Returns
    Type Description
    long

    The size of the partial view.

    View Source

    GetPartialViews(params string[])

    Gets a list of all IPartialView objects

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public IEnumerable<IPartialView> GetPartialViews(params string[] names)
    Parameters
    Type Name Description
    string[] names
    Returns
    Type Description
    IEnumerable<IPartialView>

    An enumerable list of IPartialView objects

    View Source

    GetScript(string?)

    Gets a IScript object by its name

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public IScript? GetScript(string? name)
    Parameters
    Type Name Description
    string name

    Name of the script incl. extension

    Returns
    Type Description
    IScript

    A IScript object

    View Source

    GetScriptFileContentStream(string)

    Gets the content of a script file as a stream.

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public Stream GetScriptFileContentStream(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the script.

    Returns
    Type Description
    Stream

    The content of the script file.

    View Source

    GetScriptFileSize(string)

    Gets the size of a script file.

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public long GetScriptFileSize(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the script file.

    Returns
    Type Description
    long

    The size of the script file.

    View Source

    GetScripts(params string[])

    Gets a list of all IScript objects

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public IEnumerable<IScript> GetScripts(params string[] names)
    Parameters
    Type Name Description
    string[] names
    Returns
    Type Description
    IEnumerable<IScript>

    An enumerable list of IScript objects

    View Source

    GetStylesheet(string?)

    Gets a IStylesheet object by its name

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public IStylesheet? GetStylesheet(string? path)
    Parameters
    Type Name Description
    string path

    Path of the stylesheet incl. extension

    Returns
    Type Description
    IStylesheet

    A IStylesheet object

    View Source

    GetStylesheetFileContentStream(string)

    Gets the content of a stylesheet as a stream.

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public Stream GetStylesheetFileContentStream(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the stylesheet.

    Returns
    Type Description
    Stream

    The content of the stylesheet.

    View Source

    GetStylesheetFileSize(string)

    Gets the size of a stylesheet.

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public long GetStylesheetFileSize(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the stylesheet.

    Returns
    Type Description
    long

    The size of the stylesheet.

    View Source

    GetStylesheets(params string[])

    Gets a list of all IStylesheet objects

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public IEnumerable<IStylesheet> GetStylesheets(params string[] paths)
    Parameters
    Type Name Description
    string[] paths
    Returns
    Type Description
    IEnumerable<IStylesheet>

    An enumerable list of IStylesheet objects

    View Source

    GetTemplate(Guid)

    Gets a ITemplate object by its guid identifier.

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public 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.

    View Source

    GetTemplate(int)

    Gets a ITemplate object by its identifier.

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public ITemplate? GetTemplate(int id)
    Parameters
    Type Name Description
    int id

    The identifier of the template.

    Returns
    Type Description
    ITemplate

    The ITemplate object matching the identifier, or null.

    View Source

    GetTemplate(string?)

    Gets a ITemplate object by its alias.

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public ITemplate? GetTemplate(string? alias)
    Parameters
    Type Name Description
    string alias

    The alias of the template.

    Returns
    Type Description
    ITemplate

    The ITemplate object matching the alias, or null.

    View Source

    GetTemplateDescendants(int)

    Gets the template descendants

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public IEnumerable<ITemplate> GetTemplateDescendants(int masterTemplateId)
    Parameters
    Type Name Description
    int masterTemplateId
    Returns
    Type Description
    IEnumerable<ITemplate>
    View Source

    GetTemplateFileContentStream(string)

    Gets the content of a template as a stream.

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public Stream GetTemplateFileContentStream(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the template.

    Returns
    Type Description
    Stream

    The content of the template.

    View Source

    GetTemplateFileSize(string)

    Gets the size of a template.

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public long GetTemplateFileSize(string filepath)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the template.

    Returns
    Type Description
    long

    The size of the template.

    View Source

    GetTemplates(int)

    Gets a list of all ITemplate objects

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public IEnumerable<ITemplate> GetTemplates(int masterTemplateId)
    Parameters
    Type Name Description
    int masterTemplateId
    Returns
    Type Description
    IEnumerable<ITemplate>

    An enumerable list of ITemplate objects

    View Source

    GetTemplates(params string[])

    Gets a list of all ITemplate objects

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public IEnumerable<ITemplate> GetTemplates(params string[] aliases)
    Parameters
    Type Name Description
    string[] aliases
    Returns
    Type Description
    IEnumerable<ITemplate>

    An enumerable list of ITemplate objects

    View Source

    SavePartialView(IPartialView, int?)

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public Attempt<IPartialView?> SavePartialView(IPartialView partialView, int? userId = null)
    Parameters
    Type Name Description
    IPartialView partialView
    int? userId
    Returns
    Type Description
    Attempt<IPartialView>
    View Source

    SaveScript(IScript?, int?)

    Saves a Script

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public void SaveScript(IScript? script, int? userId)
    Parameters
    Type Name Description
    IScript script

    IScript to save

    int? userId

    Optional id of the user saving the script

    View Source

    SaveStylesheet(IStylesheet?, int?)

    Saves a IStylesheet

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public void SaveStylesheet(IStylesheet? stylesheet, int? userId = null)
    Parameters
    Type Name Description
    IStylesheet stylesheet

    IStylesheet to save

    int? userId

    Optional id of the user saving the stylesheet

    View Source

    SaveTemplate(IEnumerable<ITemplate>, int)

    Saves a collection of Template objects

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public void SaveTemplate(IEnumerable<ITemplate> templates, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<ITemplate> templates

    List of Template to save

    int userId

    Optional id of the user

    View Source

    SaveTemplate(ITemplate, int)

    Saves a Template

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public void SaveTemplate(ITemplate template, int userId = -1)
    Parameters
    Type Name Description
    ITemplate template

    Template to save

    int userId
    View Source

    SetPartialViewFileContent(string, Stream)

    Sets the content of a partial view.

    Declaration
    [Obsolete("Please use IPartialViewService for partial view operations - will be removed in Umbraco 15")]
    public void SetPartialViewFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the partial view.

    Stream content

    The content of the partial view.

    View Source

    SetScriptFileContent(string, Stream)

    Sets the content of a script file.

    Declaration
    [Obsolete("Please use IScriptService for script operations - will be removed in Umbraco 15")]
    public void SetScriptFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the script.

    Stream content

    The content of the script file.

    View Source

    SetStylesheetFileContent(string, Stream)

    Sets the content of a stylesheet.

    Declaration
    [Obsolete("Please use IStylesheetService for stylesheet operations - will be removed in Umbraco 15")]
    public void SetStylesheetFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the stylesheet.

    Stream content

    The content of the stylesheet.

    View Source

    SetTemplateFileContent(string, Stream)

    Sets the content of a template.

    Declaration
    [Obsolete("Please use ITemplateService for template operations - will be removed in Umbraco 15")]
    public void SetTemplateFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    string filepath

    The filesystem path to the template.

    Stream content

    The content of the template.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX