473,701 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing Netwok Shares

I seem to be having a problem accessing networks shares. For example,
I try the following code:

File.Exists(@"\ \SERVER\share") ;

always returns false! Or even if I map the drive

File.Exists(@"Z :\")

that will always return false as well. I can't seem to find too much
information on this. I can access the drive/share through windows
explorer so I don't understand what the problem is... any ideas?

- Dan

Nov 16 '05 #1
3 2482
Here's the clincher: the program works fine when run from the command
line. But the program is actually being launced from a printer a
printer driver. The printer driver does a _wspawn() and launches my c#
program.

I don't think printer drivers can access network shares for whateve
reason. Anyway around this????

- Dan

di*******@gmail .com wrote:
I seem to be having a problem accessing networks shares. For example, I try the following code:

File.Exists(@"\ \SERVER\share") ;

always returns false! Or even if I map the drive

File.Exists(@"Z :\")

that will always return false as well. I can't seem to find too much
information on this. I can access the drive/share through windows
explorer so I don't understand what the problem is... any ideas?

- Dan


Nov 16 '05 #2
This may be a permission/mapping problem most likely due to the fact
that the printer driver is spawning the application under a different
user/credentials.
You may need to use WindowsIdentity .Impersonate to impersonate a
windows user with higher authentication and/or a Windows user that has
the drive mapped

Nov 16 '05 #3
ma**********@gm ail.com wrote:
This may be a permission/mapping problem most likely due to the fact
that the printer driver is spawning the application under a different
user/credentials.
You may need to use WindowsIdentity .Impersonate to impersonate a
windows user with higher authentication and/or a Windows user that has
the drive mapped


So I've been running some tests to figure out what the issue is and I'm
confounded about one portion of it. I created a C# test program which
prints the following to a textbox:

textBox1.Text += "Z Directory exists: " + Directory.Exist s("z:\\") + "\r\n";
textBox1.Text += "\\\\wing\\ data Directory exists: " +
Directory.Exist s("\\\\wing\\da ta") + "\r\n";
textBox1.Text += "User: " + WindowsIdentity .GetCurrent().N ame + "\r\n";
textBox1.Text += "Is Auth: " +
WindowsIdentity .GetCurrent().I sAuthenticated + "\r\n";
textBox1.Text += "Is System: " +
WindowsIdentity .GetCurrent().I sSystem + "\r\n";

I've mapped \\wing\data to z:, so I would expect the same output for
both Directory.Exist s("z:\\") and Directory.Exist s("\\\\wing\\da ta").
And it does - but as soon as I throw an impersonate() in there - even if
I'm impersonating myself, Z:\ doesn't exist but \\\\wing\\data does.

Output before impersonating myself:
Z Directory exists: True
\\wing\data Directory exists: True
User: DELL\Dan
Is Auth: True
Is System: False

Output after impersonating myself:
Z Directory exists: False
\\wing\data Directory exists: True
User: DELL\Dan
Is Auth: True
Is System: False

Why does Z:\ cease to exist!?

Bonus question: is it possible to give the NT SYSTEM account access to
z:\? Thanks,

- Dan
Nov 16 '05 #4

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

Similar topics

23
2901
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the same NT domain, each one has its own web server. The web server is always IIS 5.0.
36
16398
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:
4
2080
by: Neural | last post by:
Hi, i searched on google for a resolution for this problem but i found nothing interesting, i hope someone here will be able to help or at least hint me. The problem is simple: i'm trying to access a gile on a netwok PC, addressing it with a UNC path (ie \\servername\share\file.txt). I use the File object to do this, but i doesn't work because the remote PC is on another domain, and i have to provide credentials for that domain. I do...
6
3040
by: Bijesh | last post by:
Hi All, I've developed a Windows Service that acts as a remoting server (.NET Remoting). The client(user) is able to connect to the server and start a program by giving the executable path of the program (in the server) along with the working directory and the arguments (parameters). This works fine if I try to start programs whose executable file is present witin the local drives of the server. If the application is in a netwok drive,...
11
1295
by: Oliver | last post by:
Hi, I'm working on an ASP.NET application that allows users to upload images to a central storage area and view using a HTTP handler. This works great if the files are stored on a local drive on the web server. The problem I have is that when I move this storage area to a share on another machine with full permissions for everyone I still get System.IO.FileNotFoundException.
0
989
by: Ram | last post by:
Hey, I want to get a list of all the file shares on a server in my ActiveDirectory domain, Is there a way of doing so with the DirectoryServices namespace or the ADSI COM object? Note: My server is connected to ActiveDirectory so using the WinNT protocol wont help here... Thanks ahead sternr
1
1359
by: Craig | last post by:
My team is building an application in VS.NET 2005. To avoid a monolithic app and spread the development workload, we have a relatively small framework application that instantiates module assemblies as needed; each "module" is a relatively independent silo with its own UI, BL, and DAL that shares a common DB. The DB connection string is an app setting in the app.config. How can I access the connection string from the assemblies, either by...
4
7441
by: frikk | last post by:
I previously posted about accessing SharePoint over the web. Well I have since given up any easy means of doing this, since something else has perked my interest. Instead of going to http://sharepoint/site, why not just access \\sharepoint\site\ directly? So my question is this - How do I access that network share? If I go to start -run, and type in "\\SharPointServer\Site\Folder", windows explorer will pop up with it. I suppose I...
19
2173
by: cj | last post by:
I'm getting terrible response times trying to pull data from VFP tables using .net--like 2 minutes! Can someone help? f:\arcust01 currently contains 187,728 records and is indexed on CUSTNO i:\btn currently contains 5,999,657 records and is indexed on BTN Imports System.Data.OleDb Public Class Form1
0
8736
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
8649
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8934
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...
0
7824
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6571
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
4662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3102
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
2
2398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2035
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.