Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am working with visual studio and having trouble reading a text file to the default text editor for that machine. The code below

Hello, I am working with visual studio and having trouble reading a text file to the default text editor for that machine.

The code below is what I have currently. It will get to the right directory but when i click open on the textfile i get the error "An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll" which basically means the system cannot find the file. Could anyone tell me what I am doing wrong please?

private void buttonViewEmp_Click(object sender, EventArgs e) { openFileDialog1.FileName = "testfile"; //input openFileDialog1.Title = "testfile"; openFileDialog1.Filter = "Text Files(*.txt)|*.txt|All files(*.*)|*.*";

if (openFileDialog1.ShowDialog() == DialogResult.OK) { System.Diagnostics.Process.Start(Directory.GetCurrentDirectory() + "*.*"); }

}

I am using these namespaces

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 Microsoft.VisualBasic; using System.IO;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions

Question

How may the larceny of noncash assets be prevented?

Answered: 1 week ago