Access network shares with filesystemobject

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have a page in classic asp that accces a network drive, The code is as
follows:
<%
dim fso
dim objFolder
set fso=server.createObject("Scripting.FileSystemObject")
set objFolder=fso.GetFolder("f:\")
for each objFile in objFolder.files
response.write objFile.name & "<br>"
next
%>

(f: is a network drive)
I am trying to do the same thing in asp.net. My code behind is as follows:

Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

....

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim fso, objFolder, objFile As Object
Dim strFolder As String
fso = Server.CreateObject("Scripting.FileSystemObject")
strFolder = "f:\"
objFolder = fso.getFolder(strFolder)
For Each objFile In objFolder.files
Response.Write(objFile.name & "<br>")
Next
End Sub
End Class

Both pages run as integrated authentication with no anonymous access
allowed. it works fine in classic asp, but not in asp.net. It works in
asp.net if I access a local folder like c:\. The error I get in asp.net is:

Exception from HRESULT: 0x800A004C (CTL_E_PATHNOTFOUND).
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.IO.DirectoryNotFoundException: Exception from
HRESULT: 0x800A004C (CTL_E_PATHNOTFOUND).


.



Relevant Pages

  • Re: Access network shares with filesystemobject
    ... > Private Sub Page_Load(ByVal sender As System.Object, ... > Both pages run as integrated authentication with no anonymous access ... it works fine in classic asp, ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Noobie Error?
    ... I've created a simple asp.net page which basically takes in a cookie ... from a classic asp, and uses that cookie to retrieve session ... Exception Details: System.IO.FileNotFoundException: The specified ...
    (microsoft.public.dotnet.framework)
  • Re: Custom error page does not work (Server.GetLastError() is null)
    ... Ok, after a lot of searching, somehow it seems that i needed to add a ... // Code that runs when an unhandled error occurs ... Exception ex = Server.GetLastError; ... available on classic asp. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SWbemObjectSet generate error wbemErrFailed = 0 x80041001
    ... I changes the script code a little to log the information in the file. ... objInst.TextRepresentation when the exception occurs. ... Dim fso ... Stress test? ...
    (microsoft.public.win32.programmer.wmi)