Browse for a file and open the file.
-
Browse for a file and open the file. It browses fine; but when i open the folders am unable to see the contends.My basic idea is to browse for a file and select the file inside the selected folder. My code is private void btnBrowse_Click(object sender, EventArgs e) { FolderBrowserDialog dialogObj = new FolderBrowserDialog(); dialogObj.RootFolder = Environment.SpecialFolder.MyComputer; if (dialogObj.ShowDialog() == DialogResult.OK) ; { OpenFile(); MessageBox.Show("Hello Jane"); } } public void OpenFile() { OpenFileDialog obj = new OpenFileDialog(); obj.OpenFile(); } } } Am not sure where am going wrong or what has to be done. Thanking You
-
Browse for a file and open the file. It browses fine; but when i open the folders am unable to see the contends.My basic idea is to browse for a file and select the file inside the selected folder. My code is private void btnBrowse_Click(object sender, EventArgs e) { FolderBrowserDialog dialogObj = new FolderBrowserDialog(); dialogObj.RootFolder = Environment.SpecialFolder.MyComputer; if (dialogObj.ShowDialog() == DialogResult.OK) ; { OpenFile(); MessageBox.Show("Hello Jane"); } } public void OpenFile() { OpenFileDialog obj = new OpenFileDialog(); obj.OpenFile(); } } } Am not sure where am going wrong or what has to be done. Thanking You
I recommend you give this up and buy a basic book on C#, so you can start at the beginning. You're obvioulsy guessing what to do here. obj.ShowDialog will show the open file dialog. Then you check the DialogResult to see if the user clicked OK, and then you have a file selected. Even then, obj.OpenFile is not magically going to open the file in your program. You have a ways to go, take a step back and learn some basics.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )