Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Access network shares with filesystemobject

Reply
Thread Tools

Access network shares with filesystemobject

 
 
Josh Rolfe
Guest
Posts: n/a
 
      09-01-2005
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.FileSystemObjec t")
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).


 
Reply With Quote
 
 
 
 
Clamps
Guest
Posts: n/a
 
      09-01-2005
You could use the UNC instead.
io.file.exists(\\server\sharedfolder) instead of mapped drive letter.

"Josh Rolfe" <> wrote in message
news:%...
> 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.FileSystemObjec t")
> 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).
>
>



 
Reply With Quote
 
 
 
 
Josh Rolfe
Guest
Posts: n/a
 
      09-01-2005
Doing gives the same results - I cannot access network shares with UNC
either (although this also works fine in class asp)

"Clamps" <> wrote in message
news:e0N$...
> You could use the UNC instead.
> io.file.exists(\\server\sharedfolder) instead of mapped drive letter.
>
> "Josh Rolfe" <> wrote in message
> news:%...
>> 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.FileSystemObjec t")
>> 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).
>>
>>

>
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      09-01-2005
Mixing ASP and ASP.NET code seldom returns good results.

See this source code from the ASP.NET QuickStart
for a good example which uses native .NET Framework methods :

http://samples.gotdotnet.com/quickst.../directory.src

I put it online at : http://asp.net.do/test/dirlist2.aspx
so you can see it in action, since the above sample
has a directory mistake, but the code is the same.



Juan T. Llibre
ASP.NET FAQ : http://asp.net.do/faq/
===========================

"Josh Rolfe" <> wrote in message
news:%23T$...
> Doing gives the same results - I cannot access network shares with UNC either (although
> this also works fine in class asp)
>
> "Clamps" <> wrote in message
> news:e0N$...
>> You could use the UNC instead.
>> io.file.exists(\\server\sharedfolder) instead of mapped drive letter.
>>
>> "Josh Rolfe" <> wrote in message
>> news:%...
>>> 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.FileSystemObjec t")
>>> 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).
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Bruce Barker
Guest
Posts: n/a
 
      09-01-2005
asp runs pages with the iis authentication account defined for anonymous.
you proably specified a domain account.

asp.net runs as the asp.net account no matter the iis creditals. tell
asp.net to use the iis creditials by setting <Identity Impersonate=true> in
the web config. still must setup a domain account for anonymous.

-- bruce (sqlwork.com)



"Josh Rolfe" <> wrote in message
news:%...
>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.FileSystemObjec t")
> 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).
>



 
Reply With Quote
 
Ben
Guest
Posts: n/a
 
      09-01-2005
I don't know if any of this helps...

http://msdn.microsoft.com/library/de...SecNetch08.asp
Accessing Files on a UNC File Share
If your application needs to access files on a Universal Naming Convention
(UNC) share using ASP.NET, it is important to add NTFS permissions to the
share's folder. You will also need to set the share's permissions to grant
at least read access to either the ASP.NET process account or the
impersonated identity (if your application is configured for impersonation).



http://www.dotnetjunkies.net/Forums/...px?PostID=1531
http://west-wind.com/weblog/posts/1572.aspx



"Josh Rolfe" <> wrote in message
news:%23T$...
> Doing gives the same results - I cannot access network shares with UNC
> either (although this also works fine in class asp)
>
> "Clamps" <> wrote in message
> news:e0N$...
>> You could use the UNC instead.
>> io.file.exists(\\server\sharedfolder) instead of mapped drive letter.
>>
>> "Josh Rolfe" <> wrote in message
>> news:%...
>>> 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.FileSystemObjec t")
>>> 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).
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Network/Security issue with $ shares =?Utf-8?B?RGV2aQ==?= Wireless Networking 5 12-07-2005 06:36 PM
Access to network shares via VPN Ian Sime Cisco 2 02-04-2004 10:02 AM
NT Authentication, Network Shares, and ASP.NET =?Utf-8?B?TWFydmlu?= ASP .Net 0 01-21-2004 04:41 PM
FileSystemObject does not see folder on network middletree ASP General 7 12-19-2003 10:53 PM
Using FileSystemObject to write across the network Scott MacLean ASP General 1 09-03-2003 06:33 PM



Advertisments