Saving Image File To Specific Folder Within VB - Net Project..
Saving Image File To Specific Folder Within VB - Net Project..
By continuing to browse this site, you agree to this use. Learn more
Quick access
Answered by: Saving image file to specific folder within VB.net project...
siva.k I am a newbie to development and am stuck on a project I am working on. I have a picturebox that the
Joined Jun 2008 user populates via an OpenFileDialog. I've done this successfully. The next step is for the user to choose to
siva.k's threads add the picture to a collection. When the user clicks the add button, I would like for the picture to be saved in
1 3 10 Show activity a folder called "photos" located at the same location of the application executable file. I am able to save the
0 picture, but do not know how to point the picture to the folder I want it saved in. I want the picture to be
Sign saved there automatically, so I am not using a SaveFileDialog.
in to
vote I tried using the following line, but do not know how to make this save the file to the location I want to
save it in.
picSelectedPic.Image.Save(strFileName & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
Any suggestions? The block of code is as follows:
'Manipulates OpenFileDialog.filename so that variable 'strFileName' contains only the name of the picture...
t Fil N fdPi Fil N
strFileName = ofdPic.FileName
strFileName = strFileName.Substring(strFileName.LastIndexOf("\"))
strFileName = strFileName.Substring(1)
strFileName = strFileName.Remove(strFileName.IndexOf("."), 4)
'Saves file to the same location as the application executable ---- Should go into 'photos' folder at that
location...
picSelectedPic.Image.Save(strFileName & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
'Calls function to populate listbox with all the image files in 'photos' folder...
popImageList()
End Sub
jason
Reply | Quote
MU_Jason 40 Points
Answers
Try this code. The executablePath will also contain the executable file name.
Sign
in to
vote
Reply | Quote
siva.k 4,015 Points
In fact you can use Application.StartupPath to avoid using Substring, this goes something like this:
Regards,
Shobhit Deep
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Reply | Quote
Shobhit Deep 170 Points
py | Q
Shobhit Deep 170 Points
All replies
Try this code. The executablePath will also contain the executable file name.
Sign
in to
vote
Reply | Quote
siva.k 4,015 Points
In fact you can use Application.StartupPath to avoid using Substring, this goes something like this:
Regards,
Shobhit Deep
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Reply | Quote
Shobhit Deep 170 Points
py | Q
Shobhit Deep 170 Points
Sorry for the delayed response. Both of the suggestions were extremely helpful. I am able to use them
both in different parts of the app I'm working on. The 'application.executablepath' helped me find the files
and folders in the project and the 'application.startup' helped me to save them to where I needed to. My
extreme thanks to the both of you.
0
Sign jason
in to
vote
Tuesday, July 22, 2008 4:31 AM
Reply | Quote
MU_Jason 40 Points
Visual Studio
Programs
Microsoft Azure BizSpark (for startups)
United States (English) Newsletter Privacy & cookies Terms of use Trademarks © 2019 Microsoft