Below is my code

SW = File.CreateText("D:\\PNB\\" + System.DateTime.Now.Date.ToString("ddMMyyyy") + "_" + bn + ".txt");

Here the file is create in d:/Pnb which is hard coded
But i want to save it where the user want it to
Can any one Help me for the same

I am creating the file using Stream Writer
Stream Writer sw;
sw = file.createfile(...)
As this is creating file, can i create the file to the location specified by
SaveDialogBox

Can any one help me for the same.

Thanks for your reply
But its giving "Page not found" when i put in the url in the address bar

Think you just have to click on the link in my post and not copy and paste it.

Try this one:

string path = @"C:\1\testFile.txt";
            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                using (TextWriter tw = new StreamWriter(fs))
                {
                    //use tw variable to do writing!
                }
            }

this is not a problem
I want to save the created file where user want to store
Thanks for reply

Something like:

string chosenFilePath = System.Shell.saveFileDialog("", "*.*");
   string chosenDirectoryPath = Path.GetDirectoryName(chosenFilePath);
   string destinationPath = Path.Combine(chosenDirectoryPath, System.DateTime.Now.Date.ToString("ddMMyyyy") + "_" + bn + ".txt");
   SW = File.CreateText(destinationPath);

Sorry I don't have time to test the code above but it can be something like that :)

Also... I guess you should look for a directory selector instead of a file selector like:
System.Windows.Forms.FolderBrowserDialog

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.