Back to Devexpress

SpellCheckOptions.FileProvider Property

blazor-devexpress-dot-blazor-dot-richedit-dot-spellcheck-dot-spellcheckoptions-f1402952.md

latest3.7 KB
Original Source

SpellCheckOptions.FileProvider Property

Specifies a file provider that accesses dictionary files.

Namespace : DevExpress.Blazor.RichEdit.SpellCheck

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public IFileProvider FileProvider { get; set; }

Property Value

TypeDescription
IFileProvider

A file provider.

|

Remarks

The Dictionaries property contains all added dictionaries. A dictionary can include several files. For instance, an ISpell dictionary includes a base words file and affix file.

Assign a file provider to the FileProvider property so that the service can access dictionary files. The FileNotFoundException error occurs if you do not set the file provider, but add a dictionary.

The following code snippet sets a file provider:

csharp
public void ConfigureServices(IServiceCollection services) {
    services.AddDevExpressBlazor().AddSpellCheck(opts => {
        opts.FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "Data", "Dictionaries")
        );
        opts.MaxSuggestionCount = 7;
        opts.Dictionaries.Add(new Dictionary {
            DictionaryPath = "CustomEnglish.dic",
            AlphabetPath = "EnglishAlphabet.txt",
            Culture = "en-US"
        });
        opts.AddToDictionaryAction = (word, culture) => {
            switch (culture.Name) {
                case "en-US":
                    string path = opts.FileProvider.GetFileInfo("CustomEnglish.dic").PhysicalPath;
                    File.AppendAllText(path, word);
                    break;
                default:
                    break;
            };
        };
    });
}

Refer to the following topic for additional information: Spell Check.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FileProvider property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

blazor-richedit-spell-check/CS/SpellCheck/Program.cs#L16

csharp
builder.Services.AddDevExpressBlazor().AddSpellCheck(opts => {
    opts.FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory(), "Data", "Dictionaries"));

See Also

SpellCheckOptions Class

SpellCheckOptions Members

DevExpress.Blazor.RichEdit.SpellCheck Namespace