473,395 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Open a File using openfiledialog...

Hello!

I am trying to open a file that is selected by a user from the openfiledialog box, but the file does not open. Below is the part of the code that does so...

.................................................. ..................

OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Filter = "Text Files(*.txt)|*.txt";
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
// fdlg.OpenFile(); //this does not open the selected file
textBoxOutput.Text = fdlg.FileName;
fdlg.OpenFile(); //this does not open the selected file

}
.................................................. .....................


Please help....

Thank you....
Oct 17 '06 #1
4 5230
Banfa
9,065 Expert Mod 8TB
fdlg.OpenFile(); //this does not open the selected file

What evidence do you have for that since you do not save the the stream returned by this method?
Oct 17 '06 #2
Thank you for replying...

According to what I understand from the description of the filedialog, the method openfile opens the file that is selected by the user in the dialog box of filedialog that appears...

Please let me know if I understood something wrong...I am not sure what is to be saved for that to happen...

Thnax..
Oct 18 '06 #3
Banfa
9,065 Expert Mod 8TB
According to what I understand from the description of the filedialog, the method openfile opens the file that is selected by the user in the dialog box of filedialog that appears...
That is my understanding of the description to, however in your first post you have asserted that this doesn't happen but provided no evidence of that assertion.

Expand|Select|Wrap|Line Numbers
  1. stream^ instream = fdlg.OpenFile();
  2.  
Oct 18 '06 #4
Hello..Thanx for replying...

well, I do not understand what you mean by evidence in this case....

if you mean I need a stream reader or somthing, then I am able to read the file using a streamreader and then display the contents in a richtextbox. but what I want is that the file should open as it does when you open it up from the windows explorer....

please let me know ....
thanx again !
Oct 18 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Marge Inoferror | last post by:
Visual C#... I'd like to save some settings that are in integers and then save some lists of file names. I'm just starting off (as you can tell - no doubt.). I'm starting by trying to save...
7
by: Hareth | last post by:
How do I open a file (such as .txt) in C#..... I tried: String File; File = txtMain.Text; dlgOpen.ShowDialog(); File = dlgOpen.FileName;
2
by: JM | last post by:
Hi I have been trying to open Excel 2003 but I am having rotten luck. Just can't see to get it working. I looked at this article... ...
2
by: Lonnie | last post by:
I need to implement a simple file open dialog in my form application (C++ .NET). I know there has to be a canned version of this dialog somewhere that I can simply use, but where? How? All the...
3
by: Alex Smith | last post by:
Hi Friends, I have trying to open a PDF file in richtextbox, a .txt file open successfully but a .pdf file open with unreadable form. I have trying with OpenFileDialog fileopen = new...
4
by: MC D | last post by:
What's the best way to have a modal dialog that will only allow the selection of a FOLDER, rather than a file? Is there a property of the openFileDialog I'm missing, or is there another control...
4
by: jabslim via DotNetMonster.com | last post by:
excuse me, may i ask on how to open files only in drive "e:\" (which is my usb port for flash drives) using openfiledialog? because in the openfiledialog, even when i set my initialdirectory to...
4
by: nightscorpion | last post by:
Hello Gurus, i implemented the OpenFileDialog in my Windows Form Applications and it worked perfectly fine.However when it was run on a remote desktop i got the below error . ...
23
by: =?Utf-8?B?TWlrZTE5NDI=?= | last post by:
This is an example that is supposed to work in VB http://support.microsoft.com/kb/175512/en-us After spending a couple of hours downloading and installing VB Express 2008 after someone told me it...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.