how to save image in application folder path in c sharp

Posted by Shanky11 under Windows Forms on 10/29/2013 | Points: 10 | Views : 64651 | Status : [Member] | Replies : 6
i have created a project i need to save a image in installed application folder path
means where my set up installed there is a images folder
i need to save a image in that folder
on local its working fine
but when i create set up file then its not able to save my image there
bmp.Save(AppDomain.CurrentDomain.BaseDirectory + @"Images\temp.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
worksheet.Shapes.AddPicture(AppDomain.CurrentDomain.BaseDirectory + @"Images\temp.jpg", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 300, 250, 400, 300);




Responses

Posted by: Bandi on: 10/29/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer
http://stackoverflow.com/questions/13599599/save-png-file-in-application-image-folder-without-using-savedialogfile

EDIT:
http://www.codeproject.com/Questions/249614/get-application-path-in-csharp
http://www.c-sharpcorner.com/Forums/Thread/211316/how-to-save-image-in-specific-folder-in-windows-forms.aspx

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samirbhogayta on: 10/29/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Take a look at this sample methods and look at the overloaded methods of bitmap class

private void button11_Click(object sender, EventArgs e)
{
try {

Bitmap b = new Bitmap("name of the file");

b.Save("path of the folder to save");

Bitmap b = new Bitmap(@"C:\Documents and Settings\Desktop\7506.jpg");

b.Save(@"C:\Extract\test.jpg");
}
catch( Exception ex )
{
MessageBox .Show (ex.Message );
}

}


Hope it helps,

SAMIR
Sr. Software Engineer

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/29/2013 [Member] Starter | Points: 25

Up
0
Down
Bitmap bmp = new Bitmap(image);
bmp.Save(AppDomain.CurrentDomain.BaseDirectory + @"Images\temp.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
worksheet.Shapes.AddPicture(AppDomain.CurrentDomain.BaseDirectory + @"Images\temp.jpg", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 300, 250, 400, 300);
This is runing ok but when i change this into set up file
its not able to save my file under image folder installed in user c drive where software installs

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link for getting startup path where executable is located
http://stackoverflow.com/questions/3343206/how-to-create-a-folder-in-the-application-installed-directory
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx

And check whether Images folder exists or not in that path... If NOT, create folder programmatically
http://www.codeproject.com/Questions/419364/Check-folder-exists-and-create-if-not-using-Csharp

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susannamoore53 on: 2/20/2014 [Member] Starter | Points: 25

Up
0
Down
You may check this method:public static void SaveImageFile(REImage image, string filePath);http://www.rasteredge.com/how-to/csharp-imaging/imaging-saving-printing/ . It does help with my C# imaging project.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Arronlee on: 4/14/2014 [Member] Starter | Points: 25

Up
0
Down
Hi, I also have some tutorials for saving images in C#.NET platform ( http://www.yiigo.com/guides/csharp/how-to-save-print-image.shtml ). I hope it helps a swell. Good luck.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response