using Microsoft.AspNetCore.Components;
using NLog;
namespace Lux.UI.Components
{
public class BaseComp
{
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
///
/// Base path x network share files
///
private string basePath = "unsafe_uploads";
#endregion Private Fields
#region Private Properties
[Inject]
private IConfiguration Config { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private void ConfInit()
{
basePath = Config.GetValue("ServerConf:FileSharePath") ?? "unsafe_uploads";
}
///
/// Restituisce il contenuto del file salvato
///
///
///
///
private string LoadFileContent(string folderPath, string secureName)
{
string answ = "";
if (!string.IsNullOrEmpty(folderPath))
{
try
{
// calcolo path file...
string filePath = Path.Combine(basePath, folderPath, secureName);
if (File.Exists(filePath))
{
answ = File.ReadAllText(filePath);
}
}
catch (Exception exc)
{
Log.Error($"Exception on LoadFileContent{Environment.NewLine}{exc}");
}
}
return answ;
}
#endregion Private Methods
}
}