| Author: RamyaNaidu 06 Aug 2008 | Member Level: Silver Points : 2 |
private void btn_Click(object sender, EventArgs e) { openFileDialog.InitialDirectory = @":D\\"; openFileDialog.Filter = "Text files (*.txt)|*.txt|" + "DWGfiles (*.*)|*.*"; openFileDialog.FilterIndex = 1;
if (openFileDialog.ShowDialog() == DialogResult.OK) { MessageBox.Show(openFileDialog.FileName.ToString()); FileInfo File = new FileInfo("D:\\hhh.txt"); if (File.Exists) { StreamReader reader = new StreamReader(openFileDialog.FileName); try { strFileName = openFileDialog.FileName; txt.Text = reader.ReadToEnd(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { reader.Close(); MessageBox.Show("File exists");
} } else { FileInfo MyFile = new FileInfo(@"D:\\hhh.txt"); MyFile.Create(); MessageBox.Show("File Successfully Created."); }
} }
|
| Author: RamyaNaidu 06 Aug 2008 | Member Level: Silver Points : 2 |
private void btn_Click(object sender, EventArgs e) { openFileDialog.InitialDirectory = @":D\\"; openFileDialog.Filter = "Text files (*.txt)|*.txt|" + "DWGfiles (*.*)|*.*"; openFileDialog.FilterIndex = 1;
if (openFileDialog.ShowDialog() == DialogResult.OK) { MessageBox.Show(openFileDialog.FileName.ToString()); FileInfo File = new FileInfo("D:\\hhh.txt"); if (File.Exists) { StreamReader reader = new StreamReader(openFileDialog.FileName); try { strFileName = openFileDialog.FileName; txt.Text = reader.ReadToEnd(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { reader.Close(); MessageBox.Show("File exists");
} } else { FileInfo MyFile = new FileInfo(@"D:\\hhh.txt"); MyFile.Create(); MessageBox.Show("File Successfully Created."); }
} }
|