?
Solved

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

Posted on 2013-01-21
4
Medium Priority
?
2,240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

765 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