In this question I'm using Visual Studio 2008. My code is quite simple, as it was used from a reference I grabbed off the web. I'm using ASP/VB.Net, IIS6.0 on a Windows Server 2003 box.
I've looked at various sources online, and have not been able to piece together a proper result.
The purpose of this is to list a slew of directories and their respective files, and allow the user to eventually manage that directory (such as open and delete files).
Here is my ASPX page:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DirectoryList.aspx.vb" Inherits="VCMReports.DirectoryList" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<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">
<Columns>
<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>
And here is the CodeBehind:
Imports System.IO
Imports System.IO.DirectoryInfo
Partial Public Class DirectoryList
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dirInfo As New DirectoryInfo(Server.MapPath("V:\Users\"))
articleList.DataSource = dirInfo.GetFiles("V:\Users\")
articleList.DataBind()
End Sub
Protected Sub GetFiles()
Dim files() As String = Directory.GetFiles("V:\Users\")
Dim myDir As DirectoryInfo = New DirectoryInfo("V:\Users\")
Dim fileInfos() As IO.FileInfo = myDir.GetFiles("*.*")
End Sub
When launching the page, the following error appears:
'V:\Users\' is not a valid virtual path.
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.Web.HttpException: 'V:\Users\' is not a valid virtual path.
Things I have tried:
- On the server, I have mapped out the drive and the directory.
- Permissions seem to be properly set, impersonate is correct.
- If I were to list a directory in the actual directory "C:\Inetpub\Directory\", there is no failure.
- I do understand this is incomplete for the Directory listing portion, this will only list files (so this will need to be modified.
- I have attempted to create a Virtual Directory, and the application presented the same error.
- On my local development machine, I have the same path created - same error.
How am I able to view the contents of a shared directory and it's files?