473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2464
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**********@gmail.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.Exists("z:\\") + "\r\n";
textBox1.Text += "\\\\wing\\data Directory exists: " +
Directory.Exists("\\\\wing\\data") + "\r\n";
textBox1.Text += "User: " + WindowsIdentity.GetCurrent().Name + "\r\n";
textBox1.Text += "Is Auth: " +
WindowsIdentity.GetCurrent().IsAuthenticated + "\r\n";
textBox1.Text += "Is System: " +
WindowsIdentity.GetCurrent().IsSystem + "\r\n";

I've mapped \\wing\data to z:, so I would expect the same output for
both Directory.Exists("z:\\") and Directory.Exists("\\\\wing\\data").
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
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...
36
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...
4
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...
6
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...
11
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...
0
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...
1
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...
4
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...
19
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.