chore: offload img folder to appdata

This commit is contained in:
2026-03-03 13:58:33 +01:00
parent 808b0c4720
commit fe5d22a811
4 changed files with 15 additions and 6 deletions

View File

@@ -8,12 +8,15 @@ namespace CarManagerV3
/// </summary>
internal class ImageManager
{
private static string _imagePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\CarManagerV3\\images";
/// <summary>
/// Initializes the image folder by creating it if it does not exist.
/// </summary>
public static void InitializeImageFolder()
{
string path = "images";
string path = _imagePath;
if (!System.IO.Directory.Exists(path))
{
@@ -31,7 +34,7 @@ namespace CarManagerV3
/// <returns>The image path for this Car.</returns>
public static string GetImagePath(Car car)
{
string basePath = "images/";
string basePath = $"{_imagePath}/";
string fileName = $"{car.Make}_{car.Model}_{car.Year}_{car.Color}.png";
return basePath + fileName;
}
@@ -60,7 +63,7 @@ namespace CarManagerV3
}
try
{
return Image.FromFile("images/no_image_available.png");
return Image.FromFile($"{_imagePath}/no_image_available.png");
}
catch (Exception ex)
{
@@ -97,7 +100,7 @@ namespace CarManagerV3
catch
{
// if error, use fallback image no_image_available.png
System.IO.File.Copy("images/no_image_available.png", path);
//System.IO.File.Copy($"{_imagePath}/no_image_available.png", path);
}
}