mera ye class h:
using System.Linq;
using System.Text.RegularExpressions;

namespace Analytics.Business.Helpers;

public static class FileNameHelper
{
    public static string SanitizeFileName(string inputValue)
    {
        try
        {
            // Remove Windows-invalid characters
            inputValue = Regex.Replace(inputValue, @"[<>:\""/\\|?*]", "");

            // Remove control characters (like \r, \n, \u0001 etc.)
            inputValue = new string(inputValue.Where(ch => !char.IsControl(ch)).ToArray());

            if (string.IsNullOrWhiteSpace(inputValue)) {
                return inputValue;
            }
            string fileExtension = GetExtension(inputValue);
            string fileNameWithoutExtension = GetFileNameWithoutExtension(inputValue);

            string allowedPattern = @"[^a-zA-Z0-9@#$^&()\-_+=\{\}\[\]'`\. ]";
            string sanitizedFileName = Regex.Replace(fileNameWithoutExtension, allowedPattern, "");

            sanitizedFileName = sanitizedFileName.TrimStart('.').TrimEnd('.').Trim();

            if (!string.IsNullOrEmpty(fileExtension))
            {
                sanitizedFileName += "." + fileExtension.TrimStart('.');
            }
            return sanitizedFileName;
        }
        catch
        {
            return inputValue;
        }
    }


    private static string GetExtension(string path)
    {
        if (string.IsNullOrWhiteSpace(path))
        {
            return string.Empty;
        }
        int i = path.LastIndexOf('.');
        if (i >= 0 && i < path.Length - 1)
        { 
            return path.Substring(i);
        }
        return string.Empty;
    }

    private static string GetFileNameWithoutExtension(string path)
    {
        if (string.IsNullOrWhiteSpace(path))
        {
            return string.Empty;
        }
        int slash = path.LastIndexOfAny(new[] { '/', '\\' });
        int dot = path.LastIndexOf('.');
        if (dot > slash)
        {
            return path.Substring(slash + 1, dot - slash - 1);
        }
        return path.Substring(slash + 1);
    }
}
or ek business layer m method h:
 private string BuildProgramPerformanceFileName(List<Programs> programNameModel)
 {
     //    string sanitizedProgramName = FileNameHelper.SanitizeFileName(
     //    string.Join("_", programNameModel.Select(p => p.ProgramName.Replace(" ", "_")))
     //);
     string staticProgramName = "Alpha Program_Beta Initiative_Gamma Wave ! @ # $ % ^ & * ( ) _ + - = { } [ ] | \\ : ; \" ' < > , . ? / ! @ # $ % ^ & * ( ) _ + - = { } [ ] | \\ : ; \" ' < > , . ? / ! @ # $ % ^ & * ( ) _ + - = { } [ ] | \\\r\n";
     string sanitizedProgramName = FileNameHelper.SanitizeFileName(staticProgramName);
     Console.WriteLine(sanitizedProgramName);
     int allowedLength = CommonConstants.ProgramPerformancePdfMaxLength - (CommonConstants.NameFormatForPdfFileNamePrefix.Length + CommonConstants.DateFormatForPdfFileNameSuffix.Length);
     if (allowedLength < 0) allowedLength = 0;

     if (sanitizedProgramName.Length > allowedLength)
         sanitizedProgramName = sanitizedProgramName.Substring(0, allowedLength);

     return $"{CommonConstants.NameFormatForPdfFileNamePrefix}{sanitizedProgramName}-{DateTime.UtcNow.ToString(CommonConstants.DateFormatForPdfFileNameSuffix)}";
 }


ye constant variables:
 public static readonly string NameFormatForPdfFileNamePrefix = "FD-Program-Performance-";
 public static readonly string DateFormatForPdfFileNameSuffix = "MMddyyyyHHmmss";


mera issue ye h ki mujhe jab pdf download ho tab uska filename ka format proper aana chahiye jisme max length 150 m cover hojaaye.
uske liye sanitize method likhi h or special characters remove krna h or blankspace ko replace _ isse

but proper work nhi krrha.
filenotfound ki error aati h .
resolve it