R
raylopez99
I can't get the below code to work, no matter how many times I change
it. I do have the Image file, Image1, created (in another method),
and using "hard coding" I can save it (it's a filled rectangle) on my
hard drive, but I cannot use the Dialog box to select a user defined
name. I keep getting the error "Wrong Parameter Selected" no matter
what name I pick. Also I got rid of the 'filters' for extensions and
it still doesn't work. saveFileDialog1 was created with the wizard.
It's something very obvious I'm sure, but I just can't figure it out
(this is my first time saving a binary file alone; for some reason I
can binary serialize and use StreamWriter/TextWriter, but with this
Image file in this saveFileDialog, nothing works).
Any ideas?
RL
Stream myStream;
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if((myStream = saveFileDialog1.OpenFile()) != null)
{
// Code to write the stream goes here.
string path0 =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string filename01 = saveFileDialog1.FileName;
// string fullpathAndFilename = path0 +"\\"+
filename01; //did not work
// string fullpathAndFilename = path0 + filename01; //also did not
work
// // Image1.Save(fullpathAndFilename,
system.Drawing.Imaging.ImageFormat.Png);//did not work
// Image1.Save(filename01); //does not work
//Image1.Save(fullpathAndFilename); //does not work
//Image1.Save(@"C:\image33.png"); //this works, but I
want a non-hard code way of entering the name
myStream.Close();
}
}
it. I do have the Image file, Image1, created (in another method),
and using "hard coding" I can save it (it's a filled rectangle) on my
hard drive, but I cannot use the Dialog box to select a user defined
name. I keep getting the error "Wrong Parameter Selected" no matter
what name I pick. Also I got rid of the 'filters' for extensions and
it still doesn't work. saveFileDialog1 was created with the wizard.
It's something very obvious I'm sure, but I just can't figure it out
(this is my first time saving a binary file alone; for some reason I
can binary serialize and use StreamWriter/TextWriter, but with this
Image file in this saveFileDialog, nothing works).
Any ideas?
RL
Stream myStream;
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if((myStream = saveFileDialog1.OpenFile()) != null)
{
// Code to write the stream goes here.
string path0 =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string filename01 = saveFileDialog1.FileName;
// string fullpathAndFilename = path0 +"\\"+
filename01; //did not work
// string fullpathAndFilename = path0 + filename01; //also did not
work
// // Image1.Save(fullpathAndFilename,
system.Drawing.Imaging.ImageFormat.Png);//did not work
// Image1.Save(filename01); //does not work
//Image1.Save(fullpathAndFilename); //does not work
//Image1.Save(@"C:\image33.png"); //this works, but I
want a non-hard code way of entering the name
myStream.Close();
}
}