Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4234370
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:20:43+00:00 2026-05-21T02:20:43+00:00

In WPF, the following code returns a list of all fonts in the given

  • 0

In WPF, the following code returns a list of all fonts in the given location:

foreach (var fontFamily in Fonts.GetFontFamilies(@"C:\Dummy\Fonts\"))
{
    System.Diagnostics.Debug.WriteLine(fontFamily.Source);
}

The problem is if you change the content of that folder (add or remove a font) and run this code again, it returns the same list (as it is cached somewhere internally).

This cache will not be cleared until you exit the application!

Is there any way to prevent this behaviour and always make WPF to look into that folder for fonts at that moment?

NOTE: The result is the same regardless of “Windows Presentation Foundation Font Cache 3.0.0.0” service state is started or stopped. Apparently this specific type of cache is not being handled by the service.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:20:44+00:00Added an answer on May 21, 2026 at 2:20 am

    I believe you may need to disable the font cache service, as it may be started automatically when needed.

    EDIT:

    You may have to get the list of FontFamily objects yourself like so:

    private static FontFamily CreateFontFamily(string path) {
        Uri uri;
        if (!Uri.TryCreate(path, UriKind.Absolute, out uri))
            throw new ArgumentException("Must provide a valid location", "path");
    
        return new FontFamily(uri, string.Empty);
    }
    
    public static IEnumerable<FontFamily> GetNonCachedFontFamilies(string location) {
        if (string.IsNullOrEmpty("location"))
            throw new ArgumentException("Must provide a location", "location");
    
        DirectoryInfo directoryInfo = new DirectoryInfo(location);
        if (directoryInfo.Exists) {
            FileInfo[] fileInfos = directoryInfo.GetFiles("*.?tf");
            foreach (FileInfo fileInfo in fileInfos)
                yield return CreateFontFamily(fileInfo.FullName);
        }
        else {
            FileInfo fileInfo = new FileInfo(location);
            if (fileInfo.Exists)
                yield return CreateFontFamily(location);
        }
    }
    

    There may be some issues with the family name, but the above should get you most of the relevant information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to load a image at runtime in WPF using the following code
I am trying my hands on WPF MVVM. I have written following code in
The following ToolTip code works in WPF . I'm trying to get it to
I am NEW to WPF. I have the following XAML code: </Window> ... <Canvas>
I got the following Design time exception for my control in WPF System.NotImplementedException The
The following code is a silverlight application but the same happens in WPF, so
I am using following code in WPF to display image in webcam usingEmguCv library
I use C#, MVVM, WPF and Resharper. When using the following code: public bool
I have the following code in a WPF 4 project, linked to an imagebox.
When I display a JPEG in my WPF application (using the following code), it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.