473,785 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot access remote file from mapped drive

I want to access files from a remote server so I mapped it in my
server under z:\ for \\myserver\web\ mysite\images\
I added this UNC path to my IIS virtual directory and name it as
"upload"
but I still cannot use any FSO to read it. Here is my code:

<%
Dim fs
set fs=Server.Creat eObject("Script ing.FileSystemO bject")

'Method one- NOT exist
if fs.FileExists(" \\myserver\web\ mysite\images\x xx.gif")=true then
response.write( "File exists!")
else
response.write( "File NOT exist!")
end if

'Method two - NOT exist as well
if fs.FileExists(" Z:\xxx.gif")=tr ue then
response.write( "File exists!")
else
response.write( "File NOT exist!")
end if

%>

But if i run this html on where my asp is located, it can read this
file -
<img src='../upload/xxx.gif' >

I tried to use server.MapPath( "../upload/") but i got this result
D:\Web\sys\uplo ad
While my asp file is located in D:\web\sys
the problem is that there's no physical drive under D:\
I really have no clue here.
All I want to do is to check if a file exists on \\myserver\web\ mysite
\images\
If yes then I am going to delete it.. that's why I need to use FSO.

Anyone has ideas?

Oct 26 '07 #1
1 9084
<ta********@gma il.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
I want to access files from a remote server so I mapped it in my
server under z:\ for \\myserver\web\ mysite\images\
I added this UNC path to my IIS virtual directory and name it as
"upload"
but I still cannot use any FSO to read it. Here is my code:

<%
Dim fs
set fs=Server.Creat eObject("Script ing.FileSystemO bject")

'Method one- NOT exist
if fs.FileExists(" \\myserver\web\ mysite\images\x xx.gif")=true then
response.write( "File exists!")
else
response.write( "File NOT exist!")
end if

'Method two - NOT exist as well
if fs.FileExists(" Z:\xxx.gif")=tr ue then
response.write( "File exists!")
else
response.write( "File NOT exist!")
end if

%>

But if i run this html on where my asp is located, it can read this
file -
<img src='../upload/xxx.gif' >

I tried to use server.MapPath( "../upload/") but i got this result
D:\Web\sys\uplo ad
While my asp file is located in D:\web\sys
the problem is that there's no physical drive under D:\
I really have no clue here.
All I want to do is to check if a file exists on \\myserver\web\ mysite
\images\
If yes then I am going to delete it.. that's why I need to use FSO.

Anyone has ideas?
The problem is that the file system object knows nothing about IIS or ASP.
Therefore the fact that you have created and virtual directory is
meaningless.

Mapped drives are a user oriented construct. Two different users can could
log on a two different times and each can get their own set of mapped
drives. When no one is logged in there are no mapped drives. Its probably
not as simplistic as that but its not good to rely on mapped drives and you
still need the appropriate priviledges to access the content.

Hence the FSO will attempt to access the share under the IUSR_<machinena me>
security token which won't have the appropriate priviledges.

You need the ASP that is using the file system object under a user account
that does have access.

One approach would be to change the anonymous user on the ASP file to a user
that has access.

However you need to be careful that this user only has read access to the
ASP file and read/write to the folder you want to modify. You need to be
sure that a malicuous formation of the URL can't go ahead and delete things
you wouldn't want deleting.
--
Anthony Jones - MVP ASP/ASP.NET
Oct 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3661
by: Mike McIntyre [MVP] | last post by:
I am working on an issue where and ASP.NET web application on one computer (A) needs to access files on a network mapped drive (B). This application uses as DSN on (A) that maps a proprietory ODBC driver to data on a (B). The DSN directory path points to mapped network drive mounted on (A). When the ASP.NET application reaches the point where the ODBC drive is called to fill a DataSet it throws the following exeption:
3
10586
by: James N | last post by:
My ASP.NET application needs read/write permissions for drive "Z:", which is mapped to my Linksys Gigadrive (Network Attached Storage...if anyone is familiar with that). If I configure the Gigadrive with "Guest" access rights, then everything works fine, BUT this leaves the drive vulnerable to everyone/everything including network viruses. Lately, my drive has had several attacks by the Lovegate virus. Eliminating such attacks...
6
13731
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the error (seems to be happening when I try creating a directory) If dirmgr.Exists("s:\blah\" & txt_name.Text) Then lblerror.Text = lblerror.Text & "Unable to build physical path. " &
2
5683
by: Peter O'Reilly | last post by:
I am experiencing difficulty access a mapped network drive in an ASP.NET application. While using the .Net framework v 1.1 implementation of System.IO.Directory.Exists(), it fails to recognize a mapped network drive. This is true if the path specified uses a mapped drive letter or is expressed as a UNC address. I have also tried the drive letter and UNC paths with and without trailing backslashes, respectively.
2
9533
by: Dave Stewart | last post by:
I am attempting to write a vb.net windows service that will automate various file movements on my network. When I attempt to access files on a mapped drive or UNC file share, I get exceptions claiming that the file is not there. However if I copy the file path directly in to explorer it pops right up. I know that my service is running as local system and this must be causing the problems. When I write the windowsidentity.getcurrent().name...
7
4489
by: Ronald S. Cook | last post by:
In my .aspx page, I am trying to read file that is on a different on the company network. When I map a drive to it and call from within my .aspx page, I get this error:
5
5367
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am trying to accesss a Mapped Drive from my asp.net code running on IIS 6.0. I am using a FileUpload control and fileUpload.SaveAs() to save the file to the server. I want to save the file to a mapped drive that is mapped to a share on the network. When I save to "C:\temp\myFile.txt it works but when I save to Z:\temp\myFile.txt is will not work. I also want to copy, delete and move these files. I have found some pages on the net...
25
3015
by: p byers | last post by:
Good Morning Folks I have a LAN Among the several connections to it are the following four devices: A MAXSTOR network Storage Device A PC running Microsoft Windows 2000 Server 5.0.2195 (SP4) A PC running Microsoft Windows XP Professional 5.1.2600 (SP2) A PC running Microsoft Windows XP Professional 5.1.2600 (SP2) All of the PCs are running IIS
4
3038
by: vbshanes | last post by:
We use Samba on a SCO Unix box as our file server / backup device. I have a directory mapped as a Windows drive. I read / write files from this remote drive with my VB,net application. This arrangement works 99.99% of the time. That being said, Windows does not automatically connect to the remote drive at system boot every once in a great while. Some of our customers have certain Windows boxes that the problem is a bit more frequent.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.