954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Accessing asp.net app directory

Hi there I am writing ASP.NET app
I want to access gif images stored in Images folder which is in turn stored in Project folder. See my Solution Explorer .

In GetImage.ashx (see solution explorer), I am unable to get images using this:

System.IO.FileStream _FileStream = new System.IO.FileStream("~/Images/" + imageFileName + ".gif", System.IO.FileMode.Open, System.IO.FileAccess.Read);

It gives exception Couldd not find a part of path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\~\Images\alien_tai_chi_md_wht.gif'.

Please help. Currently I am using full directory specification:
System.IO.FileStream _FileStream = new System.IO.FileStream(@"C:\Users\MAHESH\Desktop\s\ASPNETWebsites\WebDataDisplay\Images\"+imageFileName+".gif", System.IO.FileMode.Open, System.IO.FileAccess.Read);

Mahesha999
Newbie Poster
19 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

What's the root folder for your web server? The path seems wrong.

catherine sea
Junior Poster
126 posts since Jan 2008
Reputation Points: 25
Solved Threads: 20
 

use this will help you

System.IO.FileStream(server.MapPath("~/Images/" + imageFileName + ".gif",System.IO.FileMode.Open, System.IO.FileAccess.Read);
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: 0
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: