Click here to Skip to main content
11,480,532 members (50,259 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.5 ASP:NET
I am try to save Image through File Upload control in a sub directory or sub Folder.But I am getting a exception to

'E:\23-3-2013 ABC\Carkhojo\photos\Ford\FiestaAudi Q7 3.0 TDI quattro\Audi Q7 3.0 TDI quattro.jpg'

is not a valid virtual path.
Posted 30-Mar-13 1:03am
Comments
Mike Meinz at 30-Mar-13 6:10am
   
Is there a Drive E: ?
Does it contain a folder named 23-3-2013 ABC?
Does that folder contain a folder named Carkhojo?
Does that folder contain a folder named photos?
Does that folder contain a folder named Ford?
Does that folder contain a folder named FiestaAudi Q7 3.0 TDI quattro?

Paste the path into a Windows Explorer textbox and see what Windows Explorer says.

Start with Drive E: and select each subdirectory, in turn, to get to the lowest subdirectory, then copy paste from the Windows Explorer textbox into you source code.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

this will be Helpful for you



Server.MapPath(".") returns the current physical directory of the file (e.g. aspx) being executed
Server.MapPath("..") returns the parent directory
Server.MapPath("~") returns the physical path to the root of the application
Server.MapPath("/") returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)
  Permalink  
Comments
Marcus Kramer at 4-Apr-13 15:13pm
   
When you copy/paste from another site, cite the source or you will get flagged for plagiarism and possibly have your account terminated.
Source
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Quote:
Give only image folder name of your project..
Like this..

string pic = System.IO.Path.GetFileName(file.FileName);
string serverpath = Server.MapPath("../FiestaAudi Q7 3.0 TDI quattro");
string find = "Your Panel Name Here";

image_path = System.IO.Path.Combine(Server.MapPath("../FiestaAudi Q7 3.0 TDI quattro"), pic);
int a = serverpath.LastIndexOf(find);

file.SaveAs(image_path);
rpath = "../FiestaAudi Q7 3.0 TDI quattro" + "/" + pic;

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 215
1 Richard MacCutchan 150
2 CHill60 90
3 CPallini 70
4 Dave Kreskowiak 70
0 Sergey Alexandrovich Kryukov 7,874
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,074
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 21 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100