File Operation

Posted by Tushar under C# on 2/18/2010 | Views : 1396 | Status : [Member] | Replies : 3
Hi All friends

One textFile is strore in my Harddisk(like in D:\temp.txt)
I want to open the that File from hardDisk and the ask for the SaveAs that File C# .Net

Give me Good Link or Code

Have Nice Time

Advance Thanks




Responses

Posted by: Nishithraj on: 2/18/2010 [Member] Bronze

Up
0
Down
OpenFileDialog openFileDialog = new OpenFileDialog();

openFileDialog.Title = "Opening file";
openFileDialog.InitialDirectory = @"c:\Program Files";
openFileDialog.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
txtFileName.Text = openFileDialog.FileName;
}


Simillarly for saving using SaveFileDialog class





Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Tushar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/18/2010 [Member] Bronze

Up
0
Down
For save dialog box check the link

http://www.infopathdev.com/blogs/greg/archive/2006/03/08/Display-a-Save-As-Dialog-Box.aspx


Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Tushar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/18/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Use this code :


string oldfilepath = "C:\\a\\myfile.txt";

SaveFileDialog dlg = new SaveFileDialog();
if(dlg.ShowDialog() == DialogResult.OK)
File.Copy(oldfilepath, dlg.FileName);


This is the most simple one for u.

www.abhisheksur.com

Tushar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response