Save Image to particular folder from Openfiledialog?
I want to save images to my project folder from openfiledialog result . I don't get foler path to save . How do I get folder path ? How do I save that ? Please Help m开发者_开发知识库e.
FileDialog.FileName gives the full path to the file. And btw it is probably easier to use the SaveFileDialog because you want to save something, not open.
Hello thinzar,
private void button2_Click(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap();
this.saveFileDialog1.FileName = Application.ExecutablePath;
if (this.saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
myBitmap.Save(this.saveFileDialog1.FileName);
}
}
Bye
The System.Windows.Forms.FolderBrowserDialog allows the user to select a folder. Maybe that would be a better option?
Something alone these lines
Bitmap myImage = new Bitmap();
// draw on the image
SaveFileDialog sfd = new SaveFileDialog ();
if(sfd.ShowDialog() == DialogResult.OK)
{
myImage.Save(sfd.FileName);
}
I guess you're opening a file elsewhere and then using the results to later save stuff into the directory you opened from?
DialogResult result = OpenFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string directoryName = Path.GetDirectoryName(OpenFileDialog1.FileName);
// directoryName now contains the path
}
精彩评论