[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2013-01-21
4
Medium Priority
?
2,376 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 375 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 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 750 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 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 750 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 375 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

831 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