473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need help with ASP and File Access

As I am new to ASP.Net, I am looking for some insight on how to solve this issue.

I have a main page that loads a custom control. The custom control has a DataList
object. The DataSource is set to an array of objects which are filename, for right
now. This will change to a File ID, Directory ID, and Scaling Properties for displaying
thumbnails of pictures.

I am receiving an error -- exception.Message = "Access to the path is denied."
I am sure that this is because it is an ASP.Net project and I am trying to access
the file system.

Any information, pseudo design / object relationship / code as to how to correct
this, would be appreciated..

I am planning on caching the pictures on a directory by directory basis which I was
planning on doing in the ImageFeed class.

Here is the code I currently am using:

Thanks,
Dave
<asp:Image id=Image runat="server" ImageUrl='<%#
"ImageFeed.aspx?imageName=" +
DataBinder.Eval(Container.DataItem, "FileName") %>'>
</asp:Image>
public class ImageFeed : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string imageName = Request.QueryString["imageName"];
if (imageName != null)
{
stringdirectory = this.MapPath(@"..\Pictures");
stringfilename = directory + @"\" + imageName;

try
{
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
fs.Close();

Response.BinaryWrite(data);
}
catch (Exception ex)
{
string s = ex.Message;
}
}
}
}
Nov 18 '05 #1
1 916
Hi Dave,

It's not aproblem with your code. It's a permissions issue. ASP.Net by
default runs under an account (ASPNET) with very limited permissions. You
have to either grant that user permission to do the file ops you want to do,
or run ASP.Net under a user account with the proper permissions.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"David Elliott" <Da**********@BellSouth.net.nospam> wrote in message
news:q8********************************@4ax.com...
As I am new to ASP.Net, I am looking for some insight on how to solve this issue.
I have a main page that loads a custom control. The custom control has a DataList object. The DataSource is set to an array of objects which are filename, for right now. This will change to a File ID, Directory ID, and Scaling Properties for displaying thumbnails of pictures.

I am receiving an error -- exception.Message = "Access to the path is denied." I am sure that this is because it is an ASP.Net project and I am trying to access the file system.

Any information, pseudo design / object relationship / code as to how to correct this, would be appreciated..

I am planning on caching the pictures on a directory by directory basis which I was planning on doing in the ImageFeed class.

Here is the code I currently am using:

Thanks,
Dave
<asp:Image id=Image runat="server" ImageUrl='<%#
"ImageFeed.aspx?imageName=" +
DataBinder.Eval(Container.DataItem, "FileName") %>'>
</asp:Image>
public class ImageFeed : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string imageName = Request.QueryString["imageName"];
if (imageName != null)
{
stringdirectory = this.MapPath(@"..\Pictures");
stringfilename = directory + @"\" + imageName;

try
{
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
fs.Close();

Response.BinaryWrite(data);
}
catch (Exception ex)
{
string s = ex.Message;
}
}
}
}

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: NotGiven | last post by:
I have used dreamweaver to do a lot of php "programming" but now I need to write a real php function. I have a hosted mysql database that I need to export to MS Access. I can't use myODBC to do...
20
by: Stephan Golux | last post by:
It seems I have run afoul of an unfixable and acknowledged bug in my beloved access 97 which has no workaround other than to upgrade. Current supported upgrades are 2002 and 2003. 2003 appears...
3
by: Jeffrey | last post by:
Good day all, I have seen so many postings dealing with MS Access as a security risk and other items, yet I see now clear reason why. I would really like someone to point me in the right...
6
by: Robert | last post by:
I'm using an unbound form to upload an Excel spreadsheet into Access and I was wondering if there is a control available that would allow me select the desired file name and path. I can't seem to...
1
by: cur | last post by:
Ok, I need some help here. First of all, here's the offending bit of code: Private Sub WriteToFile(ByVal strPath As String, ByRef buffer As Byte()) Dim newFile As System.IO.FileStream = New...
8
by: D P | last post by:
Hello everyone, I am new here and I hope I can get the help I need. I will be as descriptive as possible!! I have developed an app using VB.NET that requires making a connection to an access...
4
by: Neil Gould | last post by:
Hi all, I hope this is the right group... if not, a pointer would be appreciated. Our club is setting up a web site (HTML & ASP) with some information that will be provided by an Access...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
3
by: techtonik | last post by:
Hello, everyb. Does anybody know simple cross-platform method of probing if executable binary is available and launching it. Problem no.1: test if executable file is available I'll take...
0
by: Dale | last post by:
Access 2000 I have a check scanner from Magtek, (MicrImage) This is like a "point of sale" check scanner/credit card reader. Magtek furnished 2 ocx's (MTMicrImage.ocx & SaxComm8.ocx). They also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.