Getting The folder From the application direcotry
Hi i all i have create a folder with a name XYZ . Now i would like to get that folder path and i would like to save my files in to that folder. How can i get that any help please..
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Marimuthu ArigovindasamyPosted Jun 28, 2010, 1:30 AM
string strAppPath = Application.StartupPath;
VivekhPosted Jun 28, 2010, 1:15 AM
path = System.AppDomain.CurrentDomain.BaseDirectory;
but this is saving the file in bin directory but i need to save i a seperate folder in which my application is running.
Marimuthu ArigovindasamyPosted Jun 27, 2010, 11:07 PM
if (!Directory.Exists(@"D:\Muthu\"))
{
Directory.CreateDirectory(@"D:\Muthu\");
}
//To open new save dialogue popup window:
saveFileDialog1.InitialDirectory = @"D:\Muthu\Tech\";
saveFileDialog1.Title = "Sample file";
saveFileDialog1.Filter = "All files|*.*|Text Documents (*.txt)|*.txt";
saveFileDialog1.ShowDialog();
//To save the file without opening a popup window
using (SaveFileDialog saveFileDialog2 = new SaveFileDialog())
{
saveFileDialog2.FileName = @"D:\Muthu\Tech\Sample.txt";
//To write the string value into the new text file
File.WriteAllText(saveFileDialog2.FileName, strValue);
}