Connecting Tech Pros Worldwide Help | Site Map

Accessing Mapped Network Drive from Service

Niloday
Guest
 
Posts: n/a
#1: Nov 15 '05
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


Jan Tielens
Guest
 
Posts: n/a
#2: Nov 15 '05

re: Accessing Mapped Network Drive from Service


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.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Niloday" <nilodayt@rheal.com> schreef in bericht
news:uFLgvXf0DHA.548@tk2msftngp13.phx.gbl...[color=blue]
> 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[/color]
I[color=blue]
> 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
>
>[/color]


Niloday
Guest
 
Posts: n/a
#3: Nov 15 '05

re: Accessing Mapped Network Drive from Service


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.

"Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
news:egrC5Ig0DHA.3140@tk2msftngp13.phx.gbl...[color=blue]
> Probably the account that you are using does not has the N: drive mapped[/color]
to[color=blue]
> \\FS1NS\SharedDir\. I suggest you try in your code to use the UNC
> (\\FS1NS\SharedDir\) instead of N:\Storage.
>
> --
> Greetz,
> Jan
> __________________________________
> Read my weblog: http://weblogs.asp.net/jan
> "Niloday" <nilodayt@rheal.com> schreef in bericht
> news:uFLgvXf0DHA.548@tk2msftngp13.phx.gbl...[color=green]
> > 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.[/color][/color]
When[color=blue]
> I[color=green]
> > tried to connect to a folder on mapped network drive (eg. N:\Storage[/color][/color]
that[color=blue][color=green]
> > corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find[/color][/color]
part[color=blue][color=green]
> > 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
> >
> >[/color]
>
>[/color]


Jan Tielens
Guest
 
Posts: n/a
#4: Nov 15 '05

re: Accessing Mapped Network Drive from Service


Niloday

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

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Niloday" <nilodayt@rheal.com> schreef in bericht
news:ezqqtGq0DHA.716@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi,
>
> the mapped drive works fine when i try to access from my windows[/color]
application[color=blue]
> 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[/color]
2[color=blue]
> different machine & will be accessing different shared folders on[/color]
different[color=blue]
> servers. So in order to avoid hard coding the network share I intend to[/color]
use[color=blue]
> a mapped network drive. Here again we do not have the option of reading[/color]
the[color=blue]
> network share from a file or database.
>
> thanks
> Niloday.
>
> "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
> news:egrC5Ig0DHA.3140@tk2msftngp13.phx.gbl...[color=green]
> > Probably the account that you are using does not has the N: drive mapped[/color]
> to[color=green]
> > \\FS1NS\SharedDir\. I suggest you try in your code to use the UNC
> > (\\FS1NS\SharedDir\) instead of N:\Storage.
> >
> > --
> > Greetz,
> > Jan
> > __________________________________
> > Read my weblog: http://weblogs.asp.net/jan
> > "Niloday" <nilodayt@rheal.com> schreef in bericht
> > news:uFLgvXf0DHA.548@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi All,
> > >
> > > I am trying to access a mapped network drive from a service that I[/color][/color][/color]
have[color=blue][color=green][color=darkred]
> > > created.
> > >
> > > The service needs to create/delete folders/files on a network drive.[/color][/color]
> When[color=green]
> > I[color=darkred]
> > > tried to connect to a folder on mapped network drive (eg. N:\Storage[/color][/color]
> that[color=green][color=darkred]
> > > corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find[/color][/color]
> part[color=green][color=darkred]
> > > 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[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > service (it did work from a C# windows application).
> > >
> > > Many thanks in advance
> > >
> > > Regds,
> > > Niloday
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Willy Denoyette [MVP]
Guest
 
Posts: n/a
#5: Nov 15 '05

re: Accessing Mapped Network Drive from Service


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.


"Niloday" <nilodayt@rheal.com> wrote in message
news:ezqqtGq0DHA.716@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi,
>
> the mapped drive works fine when i try to access from my windows[/color]
application[color=blue]
> 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[/color]
2[color=blue]
> different machine & will be accessing different shared folders on[/color]
different[color=blue]
> servers. So in order to avoid hard coding the network share I intend to[/color]
use[color=blue]
> a mapped network drive. Here again we do not have the option of reading[/color]
the[color=blue]
> network share from a file or database.
>
> thanks
> Niloday.
>
> "Jan Tielens" <jan@no.spam.please.leadit.be> wrote in message
> news:egrC5Ig0DHA.3140@tk2msftngp13.phx.gbl...[color=green]
> > Probably the account that you are using does not has the N: drive mapped[/color]
> to[color=green]
> > \\FS1NS\SharedDir\. I suggest you try in your code to use the UNC
> > (\\FS1NS\SharedDir\) instead of N:\Storage.
> >
> > --
> > Greetz,
> > Jan
> > __________________________________
> > Read my weblog: http://weblogs.asp.net/jan
> > "Niloday" <nilodayt@rheal.com> schreef in bericht
> > news:uFLgvXf0DHA.548@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi All,
> > >
> > > I am trying to access a mapped network drive from a service that I[/color][/color][/color]
have[color=blue][color=green][color=darkred]
> > > created.
> > >
> > > The service needs to create/delete folders/files on a network drive.[/color][/color]
> When[color=green]
> > I[color=darkred]
> > > tried to connect to a folder on mapped network drive (eg. N:\Storage[/color][/color]
> that[color=green][color=darkred]
> > > corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find[/color][/color]
> part[color=green][color=darkred]
> > > 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[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > service (it did work from a C# windows application).
> > >
> > > Many thanks in advance
> > >
> > > Regds,
> > > Niloday
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Niloday T
Guest
 
Posts: n/a
#6: Nov 15 '05

re: Accessing Mapped Network Drive from Service


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

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