Can any one help me out. here s my query. i have two button called "open " and "Save" . am using OpenFileDialog and SaveFileDialog. here s my code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Net;
namespace FileOpenDialog
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
// - Reading a file
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string data = Read(openFileDialog1.FileName);
textBox1.Text = data;
}
else
{
// nothing
}
}
// Read Method
private string Read(string file)
{
StreamReader reader = new StreamReader(file);
string data = reader.ReadToEnd();
reader.Close();
return data;
}
//Save Method
private void Save(string file, string data)
{
StreamWriter writer = new StreamWriter(file);
writer.Write(data);
writer.Close();
this.progressBar1.Value = 0;
}
button2- save the file
private void button2_Click(object sender, EventArgs e)
{
DialogResult result = saveFileDialog1.ShowDialog();
string file = saveFileDialog1.FileName.ToString();
string data = textBox1.Text;
Save(file, data);
}
}
}
My query s i need to capture how long will it take to save the file that should get displayed in the percentage format in progress bar using threading concept..
Kindly help me out.
Thanks & regards,
Priya

New Topic/Question
Reply




MultiQuote







|