473,385 Members | 1,863 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.

Access Network Location from C#

I want to access a shared folder of a different machine (Mapped to my
server) say E:\ (which is actually "\\myothermac\c$\somefolder") from
C#.

If I use
string strFolder = "E:\myNewFolder";
if (System.IO.Directory.Exists(strFolder))
{ ... }
I even tried this:
string strFolder = "\\\\myothermac\\c$\\somefolder"
if (System.IO.Directory.Exists(strFolder))
{ ... }

The condition is always false (though the folder exists). I thought it
might be
something to do with security and I enabled everyone to have full
access on the other machine. But it didnt help either.

I understand the ASPNET user will not know the mapings created by
other users. But how do I overcome this?

Could you please help me in solving this issue?

Thanks in advance.

Sekhar.
Nov 15 '05 #1
4 17337
Sekhar, I just used the following code to make sure this works and had no
problem. Are you sure the folder really exists? Are you able to map the
drive and view the folder through Explorer?

static void Main(string[] args)
{
//string dir = @"z:\";
string dir = @"\\dc\img";
Console.WriteLine(System.IO.Directory.Exists(dir)) ;
Console.Read();
}

--
Greg Ewing [MVP]
http://www.claritycon.com/

"Sekhar" <ma**@sekhar.net> wrote in message
news:f3**************************@posting.google.c om...
I want to access a shared folder of a different machine (Mapped to my
server) say E:\ (which is actually "\\myothermac\c$\somefolder") from
C#.

If I use
string strFolder = "E:\myNewFolder";
if (System.IO.Directory.Exists(strFolder))
{ ... }
I even tried this:
string strFolder = "\\\\myothermac\\c$\\somefolder"
if (System.IO.Directory.Exists(strFolder))
{ ... }

The condition is always false (though the folder exists). I thought it
might be
something to do with security and I enabled everyone to have full
access on the other machine. But it didnt help either.

I understand the ASPNET user will not know the mapings created by
other users. But how do I overcome this?

Could you please help me in solving this issue?

Thanks in advance.

Sekhar.

Nov 15 '05 #2
Greg, I tried using "@" but it still wont work. Here is what I used:

string strFldr = @"\\CovAspn\Projects\Assets";
Response.Write("<h3>" + System.IO.Directory.Exists(strFldr));
Response.End();

I even tried with the IP address of the machine and also reaching the
directory from the root (C$). If I type in the address on the Windows
Explorer, I am able to reach the other machine. I can map the drive with
the address I specify in the string.

Could it be something to do with the ASPNET user permissions?

I even tried accessing the same machine's directory - which runs the IIS
with its own IP address ("\\192.168.0.2\C$\Projects\Assets" - instead of
direct location) it wont work. But, giving a direct location
("C:\Projects\Assets") works. I tried with and without the "@".

What am I doing wrong?

Thanks for helping me.

Sekhar.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3
Chandra Sekhar wrote:
|| Greg, I tried using "@" but it still wont work. Here is what I used:
||
|| string strFldr = @"\\CovAspn\Projects\Assets";
|| Response.Write("<h3>" + System.IO.Directory.Exists(strFldr));
|| Response.End();
||
|| I even tried with the IP address of the machine and also reaching the
|| directory from the root (C$). If I type in the address on the Windows
|| Explorer, I am able to reach the other machine. I can map the drive
|| with the address I specify in the string.
||
|| Could it be something to do with the ASPNET user permissions?
||
|| I even tried accessing the same machine's directory - which runs the
|| IIS with its own IP address ("\\192.168.0.2\C$\Projects\Assets" -
|| instead of direct location) it wont work. But, giving a direct
|| location ("C:\Projects\Assets") works. I tried with and without the
|| "@".
||
|| What am I doing wrong?
||
|| Thanks for helping me.
||
|| Sekhar.
||
|| *** Sent via Developersdex http://www.developersdex.com ***
|| Don't just participate in USENET...get rewarded for it!

"ASPNET" doesn't have network access privileges, try running asp.net with another identity or impersonate another user.

Willy.
Nov 15 '05 #4
Chandra, yes, that is your problem. Try Willy's suggestion and then go from
there.

--
Greg Ewing [MVP]
http://www.claritycon.com/
"Chandra Sekhar" <ma**@sekhar.net> wrote in message
news:O7*************@tk2msftngp13.phx.gbl...
Greg, I tried using "@" but it still wont work. Here is what I used:

string strFldr = @"\\CovAspn\Projects\Assets";
Response.Write("<h3>" + System.IO.Directory.Exists(strFldr));
Response.End();

I even tried with the IP address of the machine and also reaching the
directory from the root (C$). If I type in the address on the Windows
Explorer, I am able to reach the other machine. I can map the drive with
the address I specify in the string.

Could it be something to do with the ASPNET user permissions?

I even tried accessing the same machine's directory - which runs the IIS
with its own IP address ("\\192.168.0.2\C$\Projects\Assets" - instead of
direct location) it wont work. But, giving a direct location
("C:\Projects\Assets") works. I tried with and without the "@".

What am I doing wrong?

Thanks for helping me.

Sekhar.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #5

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

Similar topics

0
by: Mark Reed | last post by:
Compaq P4, 512mb Ram, XPPro, Office 2002 Pro. 1. Before MS SQL 2000 Client install MS Access 2002 properly created a new database in MYDOCUMENTS which is redirected to h:\users\%username% via...
4
by: Peter Larsson | last post by:
Hello everybody, I'm developing a system for a company that has production at two different locations. The production is stored in an Access database at each location, and I need to find a way...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
6
by: Rob | last post by:
Hi, I am working on a project that requires a Windows Service which performs the following file transfer functions. 1. It monitors a specific local directory on a Windows 2003 Server. 2. When...
2
by: TheBurgerMan | last post by:
Hi all. I am using W2K3, .NET2 on a machine running AD and Exchange. I started getting the message below last week. I googled the error and not much was returned, but I did find this;...
13
by: Elton Cohen | last post by:
Hi newsgroup! Can anyone tell me where I should put a simple Access database file in order to be accessible for every computer in the network (same workgroup)? There does not need to be any...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
13
by: evancater | last post by:
My client wants to make their Access 2007 database available to offices around the country with multi-user permissions set to control access to the tables and forms, etc. The easiest thing would be...
3
by: aernst | last post by:
I found some helpful replies to someone's post regarding data base replication. I started approaching my problem pretty much the same way but need someone with way more knowledge than me to provide...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...
0
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,...
0
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...
0
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,...
0
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...

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.