Question

Using C#, I need help understanding how to use the OpenFileDialog Box to load a file...

Using C#, I need help understanding how to use the OpenFileDialog Box to load a file to my program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per requirement submitted above kindly find below solution.

Here new Windows Forms Application in C# is created using Visual Studio 2019 with name "OpenFileApplication".This application contains a form with name "Form1.cs".Below is the details of this form.

Form1.cs

//namespace
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
//application namespace
namespace OpenFileApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Form load event
private void Form1_Load(object sender, EventArgs e)
{
//creating object of OpenFileDialog
OpenFileDialog openFileDialog = new OpenFileDialog();
//this line is used to show dialog
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
//reading file contents using StreamReader
StreamReader reader = new StreamReader(openFileDialog.FileName);
//display file contents in the textbox
textBox1.Text = reader.ReadToEnd();
}
}
}
}

==================================

Output :Run application using F5 and will get the screen as shown below

Screen 1:example.txt

Screen 2:

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Using C#, I need help understanding how to use the OpenFileDialog Box to load a file...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to write a C++ program where I need to read in a file and...

    I need to write a C++ program where I need to read in a file and do somethings with information inside the file. We can NOT use arrays. The picture below is what is in the file. My question is how do I read in the file and return the number of studies ( the 5 in the file ) so I can pass it through an other funciton. we need to use ofstream commands.

  • i need help with a c++ program, it will be reading characters in from a file...

    i need help with a c++ program, it will be reading characters in from a file using file stream while the program is reading chartacter by charecter , it will identify what is it reading so say a file contains this x = 10; (This is one line) y = 20;    (This is one line)                                                                                                                                                                                                                             print x +y; (This is one line)                                                                                                                                                                                                                    the outcome would be this x is a word 10 is a number y is a word...

  • I need help in understanding how to get the following key values: Using any problem, be able to c...

    I need help in understanding how to get the following key values: Using any problem, be able to calculate and interpret: SV, ES, CV, SV%, CV%, SPI, CPI, EAC Budgeted Rate, EACCPI, EACSPI,CPI, TCPIBAC, TCPIEAC

  • I need help with my C homework. My teacher has developed a server that generates random...

    I need help with my C homework. My teacher has developed a server that generates random characters and numbers. I need to create a program that takes what is generated and put it in standard input form and find the amount of bytes using the sizeof() function. Also, if a random end of file occurs then it should generate a message and how many bytes have come through. Here is an example: or https://gyazo.com/3468f05cf5d50fc62d8f2ac6d988acef Please help soon! Thank You!

  • I need help understanding how to interpret a linear regression using a Hedonic Model. I have a just of what it is but I...

    I need help understanding how to interpret a linear regression using a Hedonic Model. I have a just of what it is but I am not conveying it correctly. Here is the data I had to do a regression: B is Beta by the way where PH = price of the house ($) B1BEDS = bedrooms (number) B2BATHS = bathrooms (number)     B3SQFT = area of the house (feet squared) B4LOT = area of the lot (feet squared) B5DISTANCE = distance...

  • I am in C++ programming, I need help with this assignments. The answer in this assignments...

    I am in C++ programming, I need help with this assignments. The answer in this assignments when I look for it it doesn't work in my visual studios. Can you please help me? I hardly have C in the class, if I fail I will fail the whole class and repeat this class again.   The file named Random.txt contains a long list of random numbers. Download the file to your system, then write a program that opens the file, reads...

  • Help! I need help understanding how to arrive at the correct solution. I will also need...

    Help! I need help understanding how to arrive at the correct solution. I will also need an explanation to have clarity. I would greatly appreciate it. Lefty completes the following capital asset transactions. By how much does Lefty’s AGI increase as a result of these gains/losses? Long-term gain $10,000 Short-term gain 4,000 Short-term loss 25,000

  • I need help with my assignment. It is a java program. Please make it as simple...

    I need help with my assignment. It is a java program. Please make it as simple as you can. Create an ArrayList with elements the objects of previous class. Using a simple loop populate the ArrayList with data from some arrays with data, or from console. Use a loop with iterator and write the information in a File using PrintWriter. Use this address for the file (c:\\result\\MyData.txt). Use the Scanner class to display the content of the file on console.

  • Hello, I would greatly appreciate it if anyone could help me. I saved a text file...

    Hello, I would greatly appreciate it if anyone could help me. I saved a text file in the C drive of my computer. I need to use open the text file to do my homework. But when I used the Python 3.7 to open the file, I got error message: NO SUCH FILE OR DIRECTORY. What should I do to open the file using the Python. Many thanks for your help.

  • I need help with calculating the probability using C++ . Saying that I'm only dealing with...

    I need help with calculating the probability using C++ . Saying that I'm only dealing with 2 cards . For example, if my cards are 5 & 6 what is the probablity of me going to bust ? knowing that there are 4 jacks,4 kings and queen left . I understand the concept but I don't know how to program it .

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT