Class IOFileSystemService
Implementación de IFileSystem basada en System.IO (cross‑platform).
No depende de Unity.
Inherited Members
Namespace: Serenity.FilePersistence.Infrastructure.Services
Assembly: Serenity.IOFilePersistence.Infrastructure.dll
Syntax
public class IOFileSystemService : IFileSystemService, IService, IFoundationSettings
Constructors
IOFileSystemService(ILogService)
Constructor for IOFileSystemService.
Declaration
public IOFileSystemService(ILogService logService)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogService | logService | The log service for logging purposes. |
Properties
Guid
Declaration
public string Guid { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Id
Declaration
public string Id { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
LogService
Declaration
public ILogService LogService { get; set; }
Property Value
| Type | Description |
|---|---|
| ILogService |
Methods
CreateDirectory(string)
Create a directory at the specified path, including any necessary parent directories.
Declaration
public void CreateDirectory(string directoryPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | directoryPath | The directory path to create. |
Delete(string)
Delete the file at the specified path if it exists.
Declaration
public void Delete(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path to delete. |
EnumerateFiles(string, string, bool)
Enumerate files in a directory matching a search pattern, optionally recursively.
Declaration
public IEnumerable<string> EnumerateFiles(string directoryPath, string searchPattern = "*", bool recursive = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | directoryPath | The directory path to search in. |
| string | searchPattern | The search pattern to match files (default is "*"). |
| bool | recursive | Whether to search subdirectories recursively (default is false). |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable of file paths matching the search criteria. |
Exists(string)
Check if a file exists at the specified path.
Declaration
public bool Exists(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path to check. |
Returns
| Type | Description |
|---|---|
| bool | True if the file exists, otherwise false. |
Move(string, string, bool)
Move a file from source to destination, optionally overwriting the destination if it exists.
Declaration
public void Move(string sourcePath, string destinationPath, bool overwrite = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourcePath | The source file path. |
| string | destinationPath | The destination file path. |
| bool | overwrite | Whether to overwrite the destination file if it exists (default is false). |
OpenRead(string)
Open a file for reading.
Declaration
public Stream OpenRead(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path to open. |
Returns
| Type | Description |
|---|---|
| Stream | A stream for reading the file. |
OpenWrite(string, bool)
Open a file for writing, optionally appending to it.
Declaration
public Stream OpenWrite(string path, bool append = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path to open. |
| bool | append | Whether to append to the file if it exists (default is false, which overwrites the file). |
Returns
| Type | Description |
|---|---|
| Stream | A stream for writing to the file. |