Wrox Programmer Forums
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 29th, 2010, 07:07 AM
Authorized User
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Post Delete image from Folder

Hello everybody

I display some images in a datalist by getting the images from folder.

Now, I want to delete the image in folder when I click the Delete button.

<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal">
<asp:Image ID="Image" Width="150px" Height="100px" runat="server"
ImageURL='<%# Container.DataItem %>' />
<br />
<asp:LinkButton ID="deleteButton" Text="Delete" OnClick="delete_onClick" runat="server" />

Protected Sub delete_onClick(ByVal sender As Object, ByVal e As System.EventArgs)

Dim fileName As String = TryCast(sender, String)
Dim fInfo As FileInfo
fInfo = New FileInfo(fileName)
End Sub
Here is these info error like this :

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'F:\REOX.NET505\MyAccount' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

I really appreciate all the help you can give me!
Thanks in advance
Phuc Hoang
Old May 29th, 2010, 07:11 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Isn't the error message very, very clear about the cause of the error and doesn't it offer a resolution?

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Old May 31st, 2010, 10:20 PM
Authorized User
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts

Thanks for helping me,It is work now

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete folder with php tinhbanghuu PHP How-To 4 March 26th, 2008 02:59 AM
Delete file from folder using FileOutputStream kotaiah Java Basics 1 March 8th, 2007 04:47 AM
Can Global.asa be used to delete a folder. solos Classic ASP Basics 9 February 13th, 2007 06:05 PM
How to save an image in a folder using c#.net2005 aneesh_sunu@yahoo.co.in C# 2005 1 October 31st, 2006 10:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.