Can't show files from folder/drive

Hi

I having some problems getting this ASP VB.Net script to running.
If i run it in debug, there is no errors, but i get a blank page, when i run it on my PC.
my code is:

main page
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="showfilesingrid.aspx.vb" Inherits="showfilesingrid" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
  <asp:label runat="server" id="lblMessage" Font-Italic="True" ForeColor="Red" />
  <asp:DataGrid runat="server" id="articleList" Font-Name="Verdana"
  	  AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"
	  HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
	  HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True"
	  DataKeyField="FullName"
	  OnItemDataBound="articleList_ItemDataBound"
	  OnDeleteCommand="articleList_DeleteFile">
    <Columns>
      <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete" />
      <asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name" />
      <asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
        ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
      <asp:BoundColumn DataField="Length" HeaderText="File Size"
	  	ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />
    </Columns>
  </asp:DataGrid>
    </div>
    </form>
</body>
</html>

Open in new window


Code_Behind
Imports System.IO

Partial Class showfilesingrid
    Inherits System.Web.UI.Page


    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not Page.IsPostBack Then

            'Dim dirInfo As New DirectoryInfo(Server.MapPath("/Upload"))
            Dim dirInfo As New DirectoryInfo("C:\Users\MacNitro\Documents\Visual Studio 2010\Projects\ShowNewestFileFromFolder_OK\Upload")
            'articleList.DataSource = dirInfo.GetFiles("*.pdf")
            articleList.DataSource = dirInfo.GetFiles()
            articleList.DataBind()
        End If
    End Sub

    Sub articleList_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
        ' First, make sure we're NOT dealing with a Header or Footer row
        If e.Item.ItemType <> ListItemType.Header And _
             e.Item.ItemType <> ListItemType.Footer Then
            'Now, reference the Button control that the Delete ButtonColumn 
            'has been rendered to
            Dim deleteButton As Button = e.Item.Cells(0).Controls(0)

            'We can now add the onclick event handler
            deleteButton.Attributes("onclick") = "javascript:return " & _
                       "confirm('Are you sure you want to delete the file " & _
                       DataBinder.Eval(e.Item.DataItem, "Name") & "?')"
        End If
    End Sub


    Sub articleList_DeleteFile(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
        'First, get the filename to delete
        Dim fileName As String = articleList.DataKeys(e.Item.ItemIndex)

        lblMessage.Text = "You opted to delete the file " & fileName & ".<br />" & _
            "This file could be deleted by calling: <code>File.Delete(fileName)</code><p>"

        'You would want to rebind the Directory's files to the DataGrid after
        'deleting the file...
    End Sub


End Class

Open in new window

tjgrindstedAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Use this line that you have commented out

 'Dim dirInfo As New DirectoryInfo(Server.MapPath("/Upload"))
0
tjgrindstedAuthor Commented:
Hi

The risen i have done that is bc i get the same error/blank page, so no luck with that..
0
CodeCruiserCommented:
I have just tested your code in my sample web app and it works fine. Just make sure you are using the correct path and that ASPNET user has access to that path.
0
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

tjgrindstedAuthor Commented:
Where do i setup the ASPNET user Access !?
0
CodeCruiserCommented:
Right click on folder and security tab. Is it using the anonymous IIS user or are you using windows authentication?
0
CodeCruiserCommented:
If anonymous then also give iis_usr user permissions.
0
tjgrindstedAuthor Commented:
im using Windows Authentication
0
CodeCruiserCommented:
Does the user, that access the page, exist on the computer/domain and have access to the folder?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tjgrindstedAuthor Commented:
it dident help for my problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.