473,587 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing files and folders on remote server in webApplication

I got this problem for the web application

I try to access files on a remote server. string[] dirs = Directory.GetDi rectories(@"E:\ vehicles")
E drive is a map to a network drive. I get the DirectoryNotFou ndException. How do I solve the problem or the is another way to write the code

Thank yo

Nov 15 '05 #1
1 4552
When you map a network drive, it is mapped for currently logged-on user and
is stored under HKEY_CURRENT_US ER registry key. The mapped drive will
therefore be available only for that user. When your ASP.NET application is
run, it does not have access to the mapped drive because in its context it
does not exist.

In your case, you need to worry about security rather than mapping network
drives. When you run your ASP.NET application it is executed in context of
your local ASPNET account (unless you are running your application on domain
controller) which cannot be authenticated agains computers that host shared
folders (unless you try accessing your local shared folders on your
computer). In order to access network folders when no authentication can be
performed (your case) entity which is trying to access a resource is
identified as Guest account, which is probably disabled in your case (and
should remain so).

The best solution to your problem would be impersonating a domain account
(read ASP.NET Impersonation in MSDN) and then giving that account access to
the shared folder.

Another solution, although not recommended and avoided at all costs, would
be enabling guest account on network computer you are trying to access,
which will introduce more problems than it will solve. Stick to
impersonation, it is simple and poses no threats as long as you know how to
secure the access to the registry and your web server.

Hope this helps.


Vjekoslav Babic, MCSA, MCDBA

"Z0gS" <an*******@disc ussions.microso ft.com> wrote in message
news:F7******** *************** ***********@mic rosoft.com...
I got this problem for the web application:

I try to access files on a remote server. string[] dirs = Directory.GetDi rectories(@"E:\ vehicles"); E drive is a map to a network drive. I get the DirectoryNotFou ndException. How do I solve the problem or the is another way to write the code?
Thank you

Nov 15 '05 #2

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

Similar topics

by: Tommy | last post by:
Hi I've uploaded the .aspx files and Web.config file made in VS.NET 2003 but I get this error http://empty- site.org/Login.aspx . I did change the config file as mentioned but with no luck . can somebody help ? TIA Tommy
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC path with a FSO: Set myFile = Server.CreateObject("Scripting.FileSystemObject").GetFile("\\server2\myshare\myfile.txt") this fails with an Permission Denied. here's the deal:
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different geographical locations. I have been completely unsucessful in acheiving this goal so far however. Things I have tried: Create a shortcut to ftp sight via browser then tried to map local drive to
by: Z0gS | last post by:
Hi I got this problem for the web application I try to access folders on a remote server. string dirs = Directory.GetDirectories(@"E:\vehicles") E drive is a map to a network drive. I get the DirectoryNotFoundException. How do I solve the problem or the is another way to write the code Thank you
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
by: John Fleming | last post by:
Hello, I am building a web application with the following components: 2 Web Servers - Windows Server 2003 - IIS 6 - .Net Framework version 2.0 - Reside in Domain A 2 Clustered Database Servers
by: phil.stollery | last post by:
Hi, I've currently setup a local user as described in: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT01.asp This users has been created on the remote server, and locally on our web farm servers. All access to NTFS file system has been setup and the users local privileges. However, when I add the
by: Thom Little | last post by:
I have a simple web service that requires no input and returns a character string. I created the service and FTPd it to a remote server. The .dll to the .bin directory and the single .asmx file to a directory called Services. When referenced from a webapplication running on localhost it operates correctly. When referenced from a webapplication running on the same remote server as the webservice it operates correctly.
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to a single folder called 'All Files' Do we spread them out and copy them to multiple folders like Folder 000 - Copy files from 0 to 1000 Folder 001 - Copy files from 1000 to 2000 Folder 002 - Copy files from 2000 to 2999
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...
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...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
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...
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();...
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...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.