Skip to content

CommonSaveFileDialog - File name with dots will be misinterpreted as file extension #63

@AekSbgIT

Description

@AekSbgIT

Hi,
I am using CommonSaveFileDialog with the following code lines:

CommonSaveFileDialog dialogSave = new CommonSaveFileDialog();
dialogSave.InitialDirectory = PdfOutputPath;
dialogSave.DefaultFileName = $"{DateTime.Now:yyyyMMdd}_Merged{".pdf"}";
dialogSave.Filters.Add(new CommonFileDialogFilter("PDF-Dokument", $"*.pdf"));
if (dialogSave.ShowDialog() == CommonFileDialogResult.Ok) {
     string pdfOutputFile = dialogSave.FileName;
}

But if I enter as filename without the file extension (.pdf), e.g. 'Ummeldung 01.01.2024 THURNHOFER' it will be cutted to 'Ummeldung 01.01.' - '.2024' will be interpreted as file extension from my filename.

I can prevent this behaviour, if I set
dialogSave.DefaultExtension = ".pdf";

but it seems to me, that it is a bug!

Best regards, Karl

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions