# Class FileService

Namespace
  adas_core.Application.Services

Assembly
  adas-core.Application.dll

Provides a concrete implementation of the IFileService contract for performing file-related operations.

    public class FileService : IFileService

Inheritance
  object
  FileService

Implements
  IFileService

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Constructors

### FileService(IOptions<ApiSettings>, ILogger<FileService>)

    public FileService(IOptions<ApiSettings> apiSettings, ILogger<FileService> logger)

#### Parameters

`apiSettings` IOptions<ApiSettings>
`logger` ILogger<FileService>

## Methods

### CopyUpdateFiles(ICollection<IFormFile>)

Copies the provided uploaded files into the configured update directory, creating each file on disk. Returns false if the update directory is not configured (null, empty, or whitespace); otherwise returns true after all files have been copied.

    public Task<bool> CopyUpdateFiles(ICollection<IFormFile> files)

#### Parameters

`files` ICollection<IFormFile>

  The collection of uploaded form files to be written to the update directory.

#### Returns

Task<bool>

  A task that resolves to true when every file is successfully copied, or false when the update directory is not configured.

### GetAllAssetFile(AssetTheme)

Retrieves all asset files from the subdirectory that matches the specified theme, creating the subdirectory if it does not exist. Returns an empty list when the assets directory is not configured or when an error occurs while reading the files.

    public List<AssetDto> GetAllAssetFile(FileEnum.AssetTheme themeParse)

#### Parameters

`themeParse` FileEnum.AssetTheme

  The theme used to locate the corresponding subdirectory within the assets directory.

#### Returns

List<AssetDto>

  A list of AssetDto objects containing the name, extension, and full path of each file found; an empty list if the assets directory is not configured or an error occurs.

### GetFilesInDirectory(string)

Retrieves the list of file paths contained in the specified directory. If the directory does not exist, a warning is logged and an empty list is returned; if an error occurs during retrieval, it is logged and an empty list is returned.

    public List<string> GetFilesInDirectory(string directoryPath)

#### Parameters

`directoryPath` string

  The path of the directory to search for files.

#### Returns

List<string>

  A list of file paths found in the directory, or an empty list if the directory does not exist or an error occurs.

### UploadAssetFiles(ICollection<IFormFile>, AssetTheme)

Asynchronously uploads a collection of asset files into a directory organized by the specified theme. If the assets directory is not configured, the method returns false; otherwise, it ensures the target directory exists, writes each file to disk, and returns true.

    public Task<bool> UploadAssetFiles(ICollection<IFormFile> files, FileEnum.AssetTheme themeParse)

#### Parameters

`files` ICollection<IFormFile>

  The collection of uploaded form files to persist to the assets directory.

`themeParse` FileEnum.AssetTheme

  The asset theme used to determine the subdirectory in which the files will be stored.

#### Returns

Task<bool>

  A task that resolves to `true` when the files are successfully written, or `false` when the assets directory path is not configured.