Hi all i need another help i.e i am using a sample code to save the data from the text boxes to a text file and i am saving it in to a directory. This one i hard coded to save the text file. Now i need to save it in a particular directory that user sets. Like i will opt him an option like preferences in menu there he can set a path to save his file and i would like to save the files in that path he created . How can i handle this any idea please. And also if he changes the directory i would like to move all the files to that drive he opted.
Thanks in advance...
Loading

Dorababu MekaPosted Jun 18, 2010, 6:22 AM
See this one i needed. I think you did not get my question properly.
I am having a file menu which consists of File and Options as Menu options
and File has sub options like New file, Exit and Options menu has sub-option has Set.
If i click on Set i would like to open a file dialog in which i can set my path where ever i needed like c,d,e,f or else. This path form the user i should save corresponding to the directory selected. Once he finished setting the path. He can click on new file from file menu there i will have some text boxes what ever i fill in that text boxes those i will save it to a text file. This text file should be saved in the path he opted from the Options menu he selected.
Marimuthu ArigovindasamyPosted Jun 18, 2010, 5:31 AM
using (SaveFileDialog saveFileDialog2 = new SaveFileDialog())
{
saveFileDialog2.FileName = @"C:\New Folder\Sample.txt";
File.WriteAllText(saveFileDialog2.FileName, strTextBoxValue);
}
Dorababu MekaPosted Jun 18, 2010, 5:20 AM
here i would like to save the information
Marimuthu ArigovindasamyPosted Jun 18, 2010, 5:15 AM
string strFilePath = "
saveFileDialog1.FileName = strFilePath;
If you don't want to open new "Save as" Popup window, then the below code is not required.
saveFileDialog1.InitialDirectory = @"D:\Muthu\Tech\";
saveFileDialog1.Title = "Sample file";
saveFileDialog1.Filter = "All files|*.*|Text Documents (*.txt)|*.txt";
saveFileDialog1.ShowDialog();
Dorababu MekaPosted Jun 18, 2010, 5:02 AM
I need to set the directory first like and then save it to that directory. From the menu option i will select an option like Set directory there i will set a path. I would like to read that path and then save it to that directory
Marimuthu ArigovindasamyPosted Jun 18, 2010, 5:00 AM
string strTextBoxValue = textBox1.Text;
saveFileDialog1.InitialDirectory = @"D:\Muthu\Tech\";
saveFileDialog1.Title = "Sample file";
saveFileDialog1.Filter = "All files|*.*|Text Documents (*.txt)|*.txt";
saveFileDialog1.ShowDialog();
File.WriteAllText(saveFileDialog1.FileName, strTextBoxValue);
//The below code is used to move the file from one location to another
string sDestination = @"D:\Muthu\Tech URL.txt";
string sSource = @"D:\Muthu\Tech\Tech URL.txt";
File.Copy(sSource, sDestination);
if (File.Exists(sDestination))
{
File.Delete(sSource);
}