473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

save picture without open file dialog over and over

2
i want to save picture in drive but i only want to open dialog box once at the begging and after the user can save image without open file dialog
Nov 25 '12 #1
4 6800
Rabbit
12,516 Expert Mod 8TB
That would pose a huge security risk because it would allow a person to download almost anything to a user's computer without their awareness of what is being downloaded.

The usual way to do this would be to zip all the files and have them download one zip file.
Nov 25 '12 #2
zmbd
5,501 Expert Mod 4TB
Rabbit,
Might this instead be like Access or Excel where there is a default folder location?

KeyVan,
Bytes is not a code writing nor homework service. Please provide a much more detailed description of what you are really after and please post your code - remember to format it using the <CODE/> button in the toolbar.
Nov 26 '12 #3
keyvan
2
hi i use this method for load and save picture.
Expand|Select|Wrap|Line Numbers
  1. private void button2_Click(object sender, EventArgs e)
  2.         { // Displays a SaveFileDialog so the user can save the Image
  3.             // assigned to Button2.
  4.             /*SaveFileDialog saveFileDialog1 = new SaveFileDialog();
  5.             saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
  6.             saveFileDialog1.Title = "save picture";
  7.             saveFileDialog1.ShowDialog();
  8.  
  9.             // If the file name is not an empty string open it for saving.
  10.             if (saveFileDialog1.FileName != "")
  11.             {
  12.                 // Saves the Image via a FileStream created by the OpenFile method.
  13.                 System.IO.FileStream fs =
  14.                    (System.IO.FileStream)saveFileDialog1.OpenFile();
  15.                 // Saves the Image in the appropriate ImageFormat based upon the
  16.                 // File type selected in the dialog box.
  17.                 // NOTE that the FilterIndex property is one-based.
  18.                 switch (saveFileDialog1.FilterIndex)
  19.                 {
  20.                     case 1:
  21.                         this.button2.Image.Save(fs,
  22.                            System.Drawing.Imaging.ImageFormat.Jpeg);
  23.                         break;
  24.  
  25.                     case 2:
  26.                         this.button2.Image.Save(fs,
  27.                            System.Drawing.Imaging.ImageFormat.Bmp);
  28.                         break;
  29.  
  30.                     case 3:
  31.                         this.button2.Image.Save(fs,
  32.                            System.Drawing.Imaging.ImageFormat.Gif);
  33.                         break;
  34.                 }
  35.  
  36.                 fs.Close();
  37.             }*/
  38.             saveFileDialog1.Filter = "JPEG File (*.jpg)|*.jpg|Bitmap File (*.bmp)|*.bmp|PNG File(*.png)|*.png";
  39.             if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  40.             {
  41.                 switch (Path.GetExtension(saveFileDialog1.FileName))
  42.                 {
  43.                     case ".jpg":
  44.                         pictureBox1.Image.Save(saveFileDialog1.FileName, ImageFormat.Jpeg); break;
  45.                     case ".bmp":
  46.                         pictureBox1.Image.Save(saveFileDialog1.FileName, ImageFormat.Bmp); break;
  47.                     case ".png":
  48.                         pictureBox1.Image.Save(saveFileDialog1.FileName, ImageFormat.Png); break;
  49.                 }
  50.             }
  51.         }
  52.  
  53.         private void button1_Click(object sender, EventArgs e)
  54.         {
  55.             // Wrap the creation of the OpenFileDialog instance in a using statement,
  56.             // rather than manually calling the Dispose method to ensure proper disposal
  57.             using (OpenFileDialog dlg = new OpenFileDialog())
  58.             {
  59.                 dlg.Title = "انتخاب عکس";
  60.                 dlg.Filter = "bmp files (*.bmp)|*.bmp|JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
  61.  
  62.                 if (dlg.ShowDialog() == DialogResult.OK)
  63.                 {
  64.                    // PictureBox PictureBox1 = new PictureBox();
  65.  
  66.                     // Create a new Bitmap object from the picture file on disk,
  67.                     // and assign that to the PictureBox.Image property
  68.                     pictureBox1.Image = new Bitmap(dlg.FileName);
  69.                 }
  70.             }
  71.         }
  72.     }
when i want to save picture the open file dialog was opened and after get file name and path is save picture i want to select path before load open dialog and file name before that open.
Nov 26 '12 #4
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

I thought this was for a website, which was why I mentioned the zip file. But apparently that is not the case.

Instead, what you want to do is declare a global variable for the path and call the dialog only if it hasn't been populated yet.
Nov 26 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bernavich2004 | last post by:
Ok I am going nuts. This problem ONLY happens when I use a Microsoft Office 2003 product like word, or .NET development IDE. WHen I use the Open file dialog and click on a folder to drill down,...
1
by: N. Graves | last post by:
Help me please? I'm have users import tables from other Access Database in one of the process needed to use my ADB. To do this the user opens a form with a field for the file directory and...
0
by: ungvichian | last post by:
I am trying to write a program in VC++.Net that will read a text file with wireframe data in it and display the wireframe it represents. This link has a sample of the code I'm basing my program off...
2
by: nissiml | last post by:
hi, i'm trying to open a asp.net web page that list files from a Windows application like winword and select a file from it . what do i have to do to make it happen, is it simple ? Thanks in...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
1
by: klaydze | last post by:
hi, i don't know how to start my code in uploading an image using open file dialog control. any one who can help me? i want to view the picture that i want to upload using open file dialog and show...
1
by: Mike P | last post by:
Is is possible to create an open file dialog box in ASP.NET that allows the user to save a file to whatever directory they choose locally? *** Sent via Developersdex http://www.developersdex.com...
3
by: motogirl | last post by:
I don t knw if im in the right place but please i need help u need to make an open file dialog so that the user can browse an image then i have to save the image. I already did the...
4
by: AndersAnd87 | last post by:
Hello, everyone! I am trying to create an application like Notepad in Visual Basic 2005. But how can I make this application read all text from a text file without having to display an Open File...
1
by: Ecohouse | last post by:
I'm trying to use the File Dialog to select an open a file. Here is my code: Set fd = Application.FileDialog(msoFileDialogOpen) With fd If .Show = True Then .AllowMultiSelect = False ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.