Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0
hi,,,
 
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
Comments
Zoltán Zörgő at 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...
See MSDN: http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.safefilenames.aspx
Member 9501115 at 30-Mar-13 8:35am
   
i want all selected filenames with extensions.
Zoltán Zörgő at 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 at 30-Mar-13 8:49am
   
yes..i need with ';' separator
ThePhantomUpvoter at 30-Mar-13 9:00am
   
Okay so do it. What is the problem exactly?
Member 9501115 at 30-Mar-13 9:03am
   
i m not able to split this array
ThePhantomUpvoter at 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
good
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.
  Permalink  
Comments
Member 9501115 at 30-Mar-13 14:04pm
   
Thanks..... it works....
 
SpeedTest.png ; Untitled.png
Zoltán Zörgő at 30-Mar-13 14:10pm
   
Great. Than feel free to accept my answer.
Member 9501115 at 30-Mar-13 14:19pm
   
can look into this:
 
http://www.codeproject.com/Questions/570053/bestpluswayplustoplussendplusbulkplusmailplusinplu
Rate this: bad
good
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[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 280
1 Sergey Alexandrovich Kryukov 279
2 CPallini 205
3 Maciej Los 197
4 Afzaal Ahmad Zeeshan 160
0 OriginalGriff 5,635
1 DamithSL 4,496
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 30 Mar 2013
Copyright © CodeProject, 1999-2014
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