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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:14:33+00:00 2026-05-23T00:14:33+00:00

I use OpenFileDialog class, to open and display a filename chosen. List<string> paths; private

  • 0

I use OpenFileDialog class, to open and display a filename chosen.

      List<string> paths;
    private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
    {
         label1.Text = "Now you can save the file paths or remove them from the list above";
         paths.Add(openFileDialog1.FileName);
         listBox1.DataSource=paths ;//Only one file is displayed in the listbox
         Refresh();

    }

I want the user to choose several files and display all the files that he chose in the listbox that i have. The problem is that only one file path is displayed each time. What is funny, is that i thoguht that whenever i use pahts.Add,,new filename is added, but in reality it isnt so!?!

  • 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-23T00:14:34+00:00Added an answer on May 23, 2026 at 12:14 am

    You have to set Multiselect in your file dialog to true and then use the FileNames property:

    private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
    {
       string[] files = openFileDialog1.FileNames;
       paths.AddRange(files);
       listBox1.DataSource=paths;
       Refresh();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use the OpenFileDialog class select a file OR folder? It
How do I use the OpenFileDialog class (in C#, WPF etc.) such that it
I'm trying to use the .NET class OpenFileDialog in C++ and getting a weird
I want to use the windows OpenFileDialog class in C# to browse files for
using openFileDialog will not return a filename in use, I want the filename only
We use OpenFileDialog across our application to select files. So far, we never used
USE [Fk_Test2] GO /****** Object: Table [dbo].[Owners] Script Date: 08/20/2010 16:52:44 ******/ SET ANSI_NULLS
I use OpenFileDialog to search for a specific file. When the user chooses the
How can I use openfiledialog and a picturebox and upload an image and store
Okay so what I'm trying to do is get the filename from OpenFileDialog/SaveFileDialog, only

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.