0

What i get is

src = Request.QueryString["imgsrc"];//src = "images/file 15.jpeg";

System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(src));

the second line returns System.IO.FileNotFoundException cause of the space in the path.

What should i do to encode or do something to read this kind of paths;

radu florescu
  • 4,315
  • 10
  • 60
  • 92
dtakis
  • 571
  • 1
  • 9
  • 30

1 Answers1

1

Assign Server.MapPath(src) to a temporary variable and then make sure that the path points to an existing file:

src = Request.QueryString["imgsrc"];//src = "images/file 15.jpeg";

string tempPath = Server.MapPath(src);

Debug.Assert(System.IO.File.Exists(tempPath);

System.Drawing.Image image = System.Drawing.Image.FromFile(tempPath);
Philipp Schmid
  • 5,778
  • 5
  • 44
  • 66
  • Guys, sorry my bad... I am dizzy after so much development and i forgot to rename the file in the filesystem expect from the database – dtakis Aug 26 '11 at 16:46