Solved

save image in the folder in  root in vb.net windows application

Posted on 2013-01-21
4
2,036 Views
Last Modified: 2013-02-07
how to save image in the folder in  root in vb.net windows application ?
0
Comment
Question by:mohgt
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
brendanmeyer earned 125 total points
ID: 38800791
just use the file name and dont include a path
eg:
Image.save("picture.jpg")
instead of
Image.save("c:\windows\files\picture.jpg")
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
ID: 38802071
You can use Application.StartupPath():
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx

    "Gets the path for the executable file that started the application, not including the executable name."
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
ID: 38802084
*Though on Vista and higher, this will probably require elevated permissions.  It's usually a better idea to use the Environment.SpecialFolder Enumeration:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx

    ApplicationData --> The directory that serves as a common repository for application-specific data for the current roaming user.  A roaming user works on more than one computer on a network. A roaming user's profile is kept on a server on the network and is loaded onto a system when the user logs on.

See Environment.GetFolderPath():
http://msdn.microsoft.com/en-us/library/14tx8hby.aspx
0
 
LVL 10

Assisted Solution

by:Monica P
Monica P earned 125 total points
ID: 38804375
Get The base location

 Dim base As String = AppDomain.CurrentDomain.BaseDirectory

 Dim Filename as string="test.jpeg"

   base = base + Filename   ---> (contain entire filename )

Sample Code to save image

protected void btnSubmit_Click(object sender, EventArgs e)
{
//Get Filename from fileupload control
string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName);

//Save images into Images folder

fileuploadimages.SaveAs(Server.MapPath("Images/"+filename));
                                           or
fileuploadimages.SaveAs((base ));
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question