HI
anyone knows how can I open a mapped network file in C#?
I try string file = @"T:\file.txt"; it shows me the error: "Could not find
a part of the path"
but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked
Thanks a lot 8 11812
Lam,
Are you sure that the drive mapping is available? If the mapping is
available, you should be able to pass that filename to whatever file
routines you want, and it should work.
Is this a Windows or an ASP.NET application? If it is an ASP.NET
application, the drive mappings might not be available (most likely) to the
account that the app is running under. Also, it most likely doesn't have
the rights to access the network as well.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Lam" <ja**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked
Thanks a lot
Hi,
Is T a valid network drive?
if so there is no reason for it to fail.
IIRC if your program is executing from the local computer it can access the
network.
Are you running your program from the local computer?
Beside, the error you are getting is not refering to security, so I but T is
not accesible
Unless, is this a window service? if so you have another problem, post back
if so
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Lam" <ja**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked
Thanks a lot
T is the network drive to a server
it's working cause I could browse it
the project is ASP.Net project. I write the ASPX page in C#
the application is running in local computer
so how can I make the drive available to my application?
Thanks a lot
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uG**************@TK2MSFTNGP10.phx.gbl... Lam,
Are you sure that the drive mapping is available? If the mapping is available, you should be able to pass that filename to whatever file routines you want, and it should work.
Is this a Windows or an ASP.NET application? If it is an ASP.NET application, the drive mappings might not be available (most likely) to
the account that the app is running under. Also, it most likely doesn't have the rights to access the network as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Lam" <ja**********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked
Thanks a lot
Lam,
Since it is an ASP.NET project, by default, the code runs under the
ASPNET local account, which does not have access to the network. Also, by
default, that user (ASPNET) will not have the drive mapping.
Can you use the UNC name instead? It would be much easier this way.
Once you have that, you have to make sure that the code has the appropriate
permissions to access the network. To do this, you will have to add the
<identity> tag to your web.config file, indicating the account you want to
impersonate. However, this might be too broad, since all code in that
directory will run under that account. A better way would be to use the
WindowsImpersonationContext class. You can see an example of how to do this
in the documentation for the Impersonate method on the WindowsIdentity
class.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Lam" <ja**********@hotmail.com> wrote in message
news:eR**************@tk2msftngp13.phx.gbl... T is the network drive to a server it's working cause I could browse it the project is ASP.Net project. I write the ASPX page in C# the application is running in local computer
so how can I make the drive available to my application?
Thanks a lot
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:uG**************@TK2MSFTNGP10.phx.gbl... Lam,
Are you sure that the drive mapping is available? If the mapping is available, you should be able to pass that filename to whatever file routines you want, and it should work.
Is this a Windows or an ASP.NET application? If it is an ASP.NET application, the drive mappings might not be available (most likely) to the account that the app is running under. Also, it most likely doesn't have the rights to access the network as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Lam" <ja**********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... > HI > anyone knows how can I open a mapped network file in C#? > I try string file = @"T:\file.txt"; it shows me the error: "Could not > find > a part of the path" > but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked > > Thanks a lot > > >
Hi,
Normally you can use the UNC for the network share, now as nicholas said
the asp.net user do not have access to access the network. Either you change
the user under which the app runs or you give the asp.net user permission.
cheers,
"Lam" <ja**********@hotmail.com> wrote in message
news:eR**************@tk2msftngp13.phx.gbl... T is the network drive to a server it's working cause I could browse it the project is ASP.Net project. I write the ASPX page in C# the application is running in local computer
so how can I make the drive available to my application?
Thanks a lot
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:uG**************@TK2MSFTNGP10.phx.gbl... Lam,
Are you sure that the drive mapping is available? If the mapping is available, you should be able to pass that filename to whatever file routines you want, and it should work.
Is this a Windows or an ASP.NET application? If it is an ASP.NET application, the drive mappings might not be available (most likely) to the account that the app is running under. Also, it most likely doesn't have the rights to access the network as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Lam" <ja**********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... > HI > anyone knows how can I open a mapped network file in C#? > I try string file = @"T:\file.txt"; it shows me the error: "Could not > find > a part of the path" > but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked > > Thanks a lot > > >
right now it's using "IUSR" in my computer for anonymous access
is it the user that need to be assgined the right to access the network
drive?
I try to open the security tab on T drive (mapped network drive), I don't
see any place
where I can change the permissoin for IUSR, Do I need to change the user to
be the one
from domain or from my local computer? I also try to change the user to the
current user logged
on to the computer, it still don't work
thanks a lot for your guys' help
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:eW*************@TK2MSFTNGP09.phx.gbl... Hi,
Normally you can use the UNC for the network share, now as nicholas said the asp.net user do not have access to access the network. Either you
change the user under which the app runs or you give the asp.net user permission.
cheers,
"Lam" <ja**********@hotmail.com> wrote in message news:eR**************@tk2msftngp13.phx.gbl...T is the network drive to a server it's working cause I could browse it the project is ASP.Net project. I write the ASPX page in C# the application is running in local computer
so how can I make the drive available to my application?
Thanks a lot
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:uG**************@TK2MSFTNGP10.phx.gbl... Lam,
Are you sure that the drive mapping is available? If the mapping
is available, you should be able to pass that filename to whatever file routines you want, and it should work.
Is this a Windows or an ASP.NET application? If it is an ASP.NET application, the drive mappings might not be available (most likely) to the account that the app is running under. Also, it most likely doesn't
have the rights to access the network as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Lam" <ja**********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... > HI > anyone knows how can I open a mapped network file in C#? > I try string file = @"T:\file.txt"; it shows me the error: "Could
not > find > a part of the path" > but if I copy the file to my C dirve, and use @"C:\file.txt"; it
worked > > Thanks a lot > > >
No, IUSR_xxxx is the account used to access local resources while
"impersonating" anonymous clients, it's a local account so it can't be used
to access network resources. Note that this account is meant to be used by
asp application, asp.net should use the config.web file to configure the
"anonymous" account.
ASPNET is a service account, so again it's a local account and as such isn't
used to authenticate. However, if the server running asp.net is a AD domain
member (W2K or more), the credentials used to authenticate are the machine
account credentials (domain\machinename$).
Here are a few options in order of complexity, note that all depends on the
OS you are running on the webserver and the network environment (domain, no
domain):
- When running in a domain (but I guess you are not), set the impersonating
account in your web.config file to a domain account with access privileges
to the share.
- When running in a workgoup, you have to set the impersonating account in
your web.config file to the same account as used when connecting from your
interactive session.
- Another option is to create a new logon session in code (calling
LogonUser() to obtain a logon token) and impersonate the logon token when
accessing the remote share, note that this requires PInvoke interop calls
(LogonUser()).
- You can also create a "use record", that is map the network share in code,
but this also requires PInvoke interop calls.
- And yet another option is to store the remote access code in a COM+
application that runs with fixed credentials having remote share access
privileges.
Willy.
"Lam" <ja**********@hotmail.com> wrote in message
news:eB**************@TK2MSFTNGP10.phx.gbl... right now it's using "IUSR" in my computer for anonymous access is it the user that need to be assgined the right to access the network drive? I try to open the security tab on T drive (mapped network drive), I don't see any place where I can change the permissoin for IUSR, Do I need to change the user to be the one from domain or from my local computer? I also try to change the user to the current user logged on to the computer, it still don't work
thanks a lot for your guys' help
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:eW*************@TK2MSFTNGP09.phx.gbl... Hi,
Normally you can use the UNC for the network share, now as nicholas said the asp.net user do not have access to access the network. Either you change the user under which the app runs or you give the asp.net user permission.
cheers,
"Lam" <ja**********@hotmail.com> wrote in message news:eR**************@tk2msftngp13.phx.gbl... >T is the network drive to a server > it's working cause I could browse it > the project is ASP.Net project. I write the ASPX page in C# > the application is running in local computer > > so how can I make the drive available to my application? > > Thanks a lot > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:uG**************@TK2MSFTNGP10.phx.gbl... >> Lam, >> >> Are you sure that the drive mapping is available? If the mapping is >> available, you should be able to pass that filename to whatever file >> routines you want, and it should work. >> >> Is this a Windows or an ASP.NET application? If it is an ASP.NET >> application, the drive mappings might not be available (most likely) >> to > the >> account that the app is running under. Also, it most likely doesn't have >> the rights to access the network as well. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "Lam" <ja**********@hotmail.com> wrote in message >> news:%2****************@TK2MSFTNGP14.phx.gbl... >> > HI >> > anyone knows how can I open a mapped network file in C#? >> > I try string file = @"T:\file.txt"; it shows me the error: "Could not >> > find >> > a part of the path" >> > but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked >> > >> > Thanks a lot >> > >> > >> > >> >> > >
Hey Willy
When I look at the Web.config file, I see
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of roles]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
is it where I change the user? and how?
right now I am running server 2003 , and it's the member of our domain
my user acount is one of the domain acounts
Thanks a lot for your help
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:#j**************@TK2MSFTNGP10.phx.gbl... No, IUSR_xxxx is the account used to access local resources while "impersonating" anonymous clients, it's a local account so it can't be
used to access network resources. Note that this account is meant to be used by asp application, asp.net should use the config.web file to configure the "anonymous" account. ASPNET is a service account, so again it's a local account and as such
isn't used to authenticate. However, if the server running asp.net is a AD
domain member (W2K or more), the credentials used to authenticate are the machine account credentials (domain\machinename$). Here are a few options in order of complexity, note that all depends on
the OS you are running on the webserver and the network environment (domain,
no domain): - When running in a domain (but I guess you are not), set the
impersonating account in your web.config file to a domain account with access privileges to the share. - When running in a workgoup, you have to set the impersonating account in your web.config file to the same account as used when connecting from your interactive session. - Another option is to create a new logon session in code (calling LogonUser() to obtain a logon token) and impersonate the logon token when accessing the remote share, note that this requires PInvoke interop calls (LogonUser()). - You can also create a "use record", that is map the network share in
code, but this also requires PInvoke interop calls. - And yet another option is to store the remote access code in a COM+ application that runs with fixed credentials having remote share access privileges.
Willy. "Lam" <ja**********@hotmail.com> wrote in message news:eB**************@TK2MSFTNGP10.phx.gbl... right now it's using "IUSR" in my computer for anonymous access is it the user that need to be assgined the right to access the network drive? I try to open the security tab on T drive (mapped network drive), I
don't see any place where I can change the permissoin for IUSR, Do I need to change the user to be the one from domain or from my local computer? I also try to change the user to the current user logged on to the computer, it still don't work
thanks a lot for your guys' help
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:eW*************@TK2MSFTNGP09.phx.gbl... Hi,
Normally you can use the UNC for the network share, now as nicholas
said the asp.net user do not have access to access the network. Either you change the user under which the app runs or you give the asp.net user permission.
cheers,
"Lam" <ja**********@hotmail.com> wrote in message news:eR**************@tk2msftngp13.phx.gbl... >T is the network drive to a server > it's working cause I could browse it > the project is ASP.Net project. I write the ASPX page in C# > the application is running in local computer > > so how can I make the drive available to my application? > > Thanks a lot > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:uG**************@TK2MSFTNGP10.phx.gbl... >> Lam, >> >> Are you sure that the drive mapping is available? If the
mapping is >> available, you should be able to pass that filename to whatever file >> routines you want, and it should work. >> >> Is this a Windows or an ASP.NET application? If it is an
ASP.NET >> application, the drive mappings might not be available (most likely) >> to > the >> account that the app is running under. Also, it most likely doesn't have >> the rights to access the network as well. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "Lam" <ja**********@hotmail.com> wrote in message >> news:%2****************@TK2MSFTNGP14.phx.gbl... >> > HI >> > anyone knows how can I open a mapped network file in C#? >> > I try string file = @"T:\file.txt"; it shows me the error:
"Could not >> > find >> > a part of the path" >> > but if I copy the file to my C dirve, and use @"C:\file.txt"; it worked >> > >> > Thanks a lot >> > >> > >> > >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brad |
last post by:
I have a win2003 server workstation with multiple webs, each web has it's
own ip address. In VS2005, if I select to open an existing web site, select
Local IIS, the dialog correctly displays a...
|
by: Moumen VB.NET 2003/2005 Developer |
last post by:
How can I detect if a file sitting on a network drive is still open by another
application?
This application resides on another machine on the network?
I am using VB.NET 2003
Your help is...
|
by: Peter S. |
last post by:
I have an ASP.NET page that invokes a web control written in C#. What I want
to do is (based on the session ID) display a certain spreadsheet that exists
on a
network drive. I want the webcontrol...
|
by: Niyazi |
last post by:
Hi,
I created application that store the data in SQL SERVER that reside on
network. The client also use this application to access the resources
provided with application. But is the client want...
|
by: Paul Brady |
last post by:
I volunteer at a youth ministry agency and help them with their
student database. They have two computers, both running Windows XP.
Both have Office 2002 installed without Access, except that...
|
by: lkr0210 |
last post by:
Hello,
I am having a huge problem with one of our PC's on the network. When this PC is connected to the network, it is very slow to open or create a new file or folder. It doesn't matter if you...
|
by: Andy_Khosravi |
last post by:
I just recently changed my database that I'm running from a monolithic
DB to a split FE/BE. The front end resides on the client machine and
the BE resides on a network drive. I'm experimenting with...
|
by: shriil |
last post by:
Hi
I am facing a problem with regard to opening of Access Databases,
resident on pcs of my office network connected thru LAN, from my
machine on the network. The folders in which these...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| |