Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi

if not understood please ask again

please ...

I am working on MultiThread Windows Application c#

OpenFileDialog on Browse button click. [select and open multiple .txt Files]
Posted
Updated 4-Sep-14 2:43am
v3
Comments
Leo Chapiro 4-Sep-14 8:44am    
>if not understood please ask again
Not understood
kavitha3 4-Sep-14 9:03am    
Thanks for the reply, got the solution...
The Question is :
On Button Click -- Open OpenFileDialog ,there how to select more than one files?
[no name] 4-Sep-14 8:52am    
Please ask again
kavitha3 4-Sep-14 9:03am    
Thanks for the reply, got the solution...
The Question is :
On Button Click -- Open OpenFileDialog ,there how to select more than one files?

You can select multiple txt files in the OpenFileDialog box by holding down SHIFT or CTRL keys while selecting the files. This will return an array with the file paths. You can then assign each path to an Open process assigned to a thread,
 
Share this answer
 
Comments
kavitha3 4-Sep-14 9:00am    
Thanks ledge[nd]... :)
Another Solution :

OpenFileDialog1.Multiselect = true;


Example:-
Stream myStream = null;
OpenFileDialog Dialog = new OpenFileDialog();
Dialog.Title = "Open Text File";
Dialog.Filter = "TXT files|*.txt";
Dialog.Multiselect = true; //allows to select multiple files in openfiledialog
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Dialog.InitialDirectory = @"C:\";
if (Dialog.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = Dialog.OpenFile()) != null)
{
using (myStream)
{

string[] filePaths = Directory.GetFiles(@"D:\FolderName", "*.txt", SearchOption.AllDirectories);
foreach (string file in filePaths)
{
rtxtFile.AppendText(System.IO.File.ReadAllText(file));
Thread.Sleep(1000);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900