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 8904557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:09:47+00:00 2026-06-15T02:09:47+00:00

If a file extension is known how do you convert the extension to a

  • 0

If a file extension is known how do you convert the extension to a FileTypeIndex in the TFileSaveDialog DoExecute event?

   function TIEWin7FileSaveDialog.DoExecute: Bool;
    begin
    ...
    {Set FileType (filter) index}
    iWideTextension := ExtractFileExt(FileName);
    FileTypeIndex := ???ExtensionToFileTypeIndex(iWideExtension);???
    FileDialog.SetFileTypeIndex(FileTypeIndex);
    ...
    end;
  • 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-06-15T02:09:49+00:00Added an answer on June 15, 2026 at 2:09 am

    There’s no explicit function that would do what you want at least since one file type may be contained in more file type masks, so you can only iterate the FileTypes and check if the file type is contained or equals to the FileMask like shown below:

    function FindFirstFileType(FileDialog: TCustomFileDialog;
      const FileExt: string): UINT;
    var
      TypeIndex: Integer;
      ExtIndex: Integer;
      ExtArray: TStringDynArray;
    begin
      Result := 0;
      for TypeIndex := 0 to FileDialog.FileTypes.Count - 1 do
      begin
        ExtArray := SplitString(FileDialog.FileTypes[TypeIndex].FileMask, ';');
        for ExtIndex := 0 to High(ExtArray) do
          if ExtArray[ExtIndex] = FileExt then
            begin
              Result := TypeIndex;
              Break;
            end;
      end;
    end;
    

    And the usage (note that the input must match exactly to the filter mask):

    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: UINT;
    begin
      I := FindFirstFileType(FileOpenDialog1, '*.pas');
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that using PHP's basename() function you can strip a known file extension
how to search for file's has a known file extension like .py ?? fext
I have a file with an extension .dbs. All that I know that it's
I need to check file extension when search over a directory. if using re
I want to get the file extension of uploaded file in Marklogic server. I
I am trying to get file extension for a file in shell script. But
I want to select urls with pdf file extension and list the pdfs separately,
At the moment i get file extension of the file like : string fileExt
At this question: mod rewrite to remove file extension, add trailing slash, remove www
I want to get the file name without the file extension in Vim. I

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.