You are on page 1of 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp5
{
public partial class FrmOpenTextFile : Form
{
public FrmOpenTextFile()
{
InitializeComponent();
}

private void btnOpen_Click(object sender, EventArgs e)


{

{
openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Title = "Browse Text File";
openFileDialog1.DefaultExt = "txt";
openFileDialog1.Filter = "Text files (*.txt) |*.txt| All Files
(*.*)|*.*";
openFileDialog1.ShowDialog();

String path = openFileDialog1.FileName;

using (StreamReader streamReader = File.OpenText(path))


{
String _getText = "";
while ((_getText = streamReader.ReadLine()) != null)
{
Console.WriteLine(_getText);
lvShowText.Items.Add(_getText);
}
}
}
}
}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp4
{
public partial class FrmStudentRecord : Form
{
public FrmStudentRecord()
{
InitializeComponent();
}

private void btnRegister_Click(object sender, EventArgs e)


{
FrmRegistration register = new FrmRegistration();
register.Show();
Visible = false;
}

private void btnFind_Click(object sender, EventArgs e)


{
try
{
openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Title = "Browse Text File";
openFileDialog1.DefaultExt = "txt";
openFileDialog1.Filter = "Text files (*.txt) |*.txt| All Files
(*.*)|*.*";
openFileDialog1.ShowDialog();

String docPath = openFileDialog1.FileName;


StreamReader reader = new StreamReader(docPath);
listView1.Text = reader.ReadToEnd();
reader.Close();
}
catch (System.IO.FileNotFoundException rm)
{
MessageBox.Show(rm.Message, "File does not found",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void btnUpload_Click(object sender, EventArgs e)


{
listView1.Text = "";
MessageBox.Show("Sucessfully Uploaded!!", "Message");
}
}
}

You might also like