Click here to Skip to main content
11,922,641 members (32,917 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#3.0 C#

How to get attached or selected files into a textbox using OpenFileDialog control...?

I tried this code..

FileAttachtxt.Text =openFileDialog1.SafeFileNames.ToString();

but returning an array...
Posted 30-Mar-13 3:22am
Zoltán Zörgő 30-Mar-13 8:23am
File into textbox? What do you want exactly? Please improve your question!
Of course it return an array, because it is the array of file names. Do a loop or whatever you want...
Member 9501115 30-Mar-13 8:35am
i want all selected filenames with extensions.
Zoltán Zörgő 30-Mar-13 8:40am
There you have it in that array, but how do you intend to process them? Do you need them as a comma separated list or what?
Member 9501115 30-Mar-13 8:49am
yes..i need with ';' separator
ThePhantomUpvoter 30-Mar-13 9:00am
Okay so do it. What is the problem exactly?
Member 9501115 30-Mar-13 9:03am
i m not able to split this array
ThePhantomUpvoter 30-Mar-13 9:22am
What do you mean you are not able? It's an array.... what is there to split? Maybe you should improve your question and clearly explain the problem. Why can you not write a for or foreach loop to go through the array? Why are the array indexers not working for you? Do you want all of the filenames in one string or just one string?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this:
FileAttachtxt.Text =String.Join(";", openFileDialog1.SafeFileNames);
PS: if you don't reply to my comment, I wont be notified, so please use the page widgets in the appropriate way.
Member 9501115 30-Mar-13 14:04pm
Thanks..... it works....

SpeedTest.png ; Untitled.png
Zoltán Zörgő 30-Mar-13 14:10pm
Great. Than feel free to accept my answer.
Member 9501115 30-Mar-13 14:19pm
can look into this:
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First of all, read this: OpenFileDialog (System.Windows.Forms)[^] than have a look at: C# OpenFileDialog Tutorial[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151125.1 | Last Updated 30 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100