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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:40:13+00:00 2026-06-10T04:40:13+00:00

I have a C# Windows Forms application where I load either a XML file

  • 0

I have a C# Windows Forms application where I load either a XML file or a CSV file for some task operations. When I click the Browse button I have, an Open File Dialog box appears and I can navigate to a location on my drive and choose the file and then upload it using an Upload button.

If I load a JPG or a ZIP file or any file whose format is anything except CSV or XML, my application crashes. Is there any way of limiting the Open File Dialog box to open only CSV or XML files alone in C#?

  • 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-10T04:40:15+00:00Added an answer on June 10, 2026 at 4:40 am

    Use

    openFileDialog.Filter = "CSV files (*.csv)|*.csv|XML files (*.xml)|*.xml";
    

    this way only csv files or xml files are shown.

    Odd-numbered pipes delineate between what’s visible in the Filter dropdown and the corresponding actual file extension, and Even-numbered pipes delineate between the first entire file extension and the second.

    For example, "CSV files (*.csv)|*csv" means users will see "CSV files (*.csv)" in the filter dropdown, and that option will look for any files that match *.csv.

    In the line of code above, the pipe before "XML" indicates an entirely new filter option that will appear below the CSV option.

    Nevertheless, users can also select other filetypes if they type in the complete name – so check the filename that was selected and correct your code accordingly.

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

Sidebar

Related Questions

I have a windows forms application that reads and updates an XML file with
I have a Windows forms C# application. I want to add an xml file
I have a PictureBox on my Windows Forms application. I load a picture in
I have a Windows Forms application that uses some Application.Idle handlers to change the
I have a windows forms application, where I have declared some static variables. On
I have a .Net windows forms application, and I need to load values into
At startup of a Windows Forms application I read a XML file. If this
I have a windows forms application in .NET 3.5. There's one form with 20
I have a Windows Forms application that on it I have a RichTextBox, like
I have a Windows Forms application in C# .NET. It contains a user-drawn control

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.