Re: Cannot Map a Network Drive in C#

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

File object of .NET doesn't work on share drive. It gives me an error
saying "Login failed".

Here is the piece of code which uses Process object of
System.Diagnostic

using (Process mapDrive = new Process())
{
mapDrive.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
mapDrive.StartInfo.RedirectStandardOutput = true;
mapDrive.StartInfo.UseShellExecute = false;
mapDrive.StartInfo.FileName = "net.exe";
mapDrive.StartInfo.Arguments = " use x: " + networkPath + " " +
password + " /user:" + userName;
mapDrive.Start();
mapDrive.WaitForExit();

string output =
mapDrive.StandardOutput.ReadToEnd().ToLower(CultureInfo.InvariantCulture);
string output1 = output;
}

Jeff Dillon wrote:
Um..show the error, and show the code?

And why use "net use.."?? Just delete the file using a full UNC path?
Similar to

File.Delete @\\someserver\someshare\somefile.doc;

"-pb-" <prateekbaxi@xxxxxxxxx> wrote in message
news:1162979668.064946.101000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I am tring to map the network drive (C$) in c# from ASP.NET page and it
seems it is not working...What I really want is to delete the file from
the netwrok computer. This file is present in the default share C$.

I search the google and what I got is that this is not possible to do
in c# from web as it requires a user with appropriate rights, Based on
this I have created a new user and added him into the Administrators
group and use the Impersonate in the web.config but after this also it
is not wroking at all. Same thig is working from C# consol application
or windows application.

I have used Process object of System.IO namespace to use the net use
function and I have also tried WMI Management Class and both are not
working

Can anyone suggest where I am going wrong....

Help is much appriciated...this has taken by 4 days and still i have
not finished yet.

regards,

-pb-


.



Relevant Pages

  • Re: Cannot Map a Network Drive in C#
    ... I am tring to map the network drive in c# from ASP.NET page and it ... I have used Process object of System.IO namespace to use the net use ... function and I have also tried WMI Management Class and both are not ...
    (microsoft.public.dotnet.framework)
  • Re: Cannot Map a Network Drive in C#
    ... Someone with more of an idea about Windows might be able to help but I think ... I am tring to map the network drive in c# from ASP.NET page and it ... I have used Process object of System.IO namespace to use the net use ...
    (microsoft.public.dotnet.framework)