Accessing Mapped Network Drive from Service

N

Niloday

Hi All,

I am trying to access a mapped network drive from a service that I have
created.

The service needs to create/delete folders/files on a network drive. When I
tried to connect to a folder on mapped network drive (eg. N:\Storage that
corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find part
of path N:\".

I tried running the service in the Administrators account but the same
problem. The thing works if I directly access the network share
\\FS1NS\SharedDir\.

Can anybody please throw some light on whats happening here? Is there
anykind of restriction on access to the mapped drives when tried from a
service (it did work from a C# windows application).

Many thanks in advance

Regds,
Niloday
 
J

Jan Tielens

Probably the account that you are using does not has the N: drive mapped to
\\FS1NS\SharedDir\. I suggest you try in your code to use the UNC
(\\FS1NS\SharedDir\) instead of N:\Storage.
 
N

Niloday

Hi,

the mapped drive works fine when i try to access from my windows application
developed in C#, however the same does not work when i try it from windows
service developed in C#.

The main purpose for doing this is becuase the service will be running on 2
different machine & will be accessing different shared folders on different
servers. So in order to avoid hard coding the network share I intend to use
a mapped network drive. Here again we do not have the option of reading the
network share from a file or database.

thanks
Niloday.
 
J

Jan Tielens

Niloday

You could store the string value for the share in a config file for example,
so you don't need to hardcode it.
 
W

Willy Denoyette [MVP]

The drive mapping belongs to the interactive logon session, the service runs
in a private logon session (even if they both are running as administrator)
and as such has no corresponding network share for drive N. The only options
you have are (preferably) to use UNC names or map the drive in your service
code.

Willy.
 
N

Niloday T

Hi,

Many thanks for all your replies.

After beating around a lot, I have realised that, I cannot access the
mapped network drive from the windows service. -what a strange thing :(

Finally I have used a config file to store the UNC (with no other
options left).

Thanks anyway to all of you. Looking forward for your support in
future.

Regds,

Niloday
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top