Mapping a Drive

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Hello all:

Is there a way to map a drive programatically in .NET?

The reason why I ask is I am trying write a program that can map local
c: drive of each computer on our domain so that I can access a certain
file, open it, and read its contents.

Thanks,

- John -
 
John,

I can think of a couple of ways of doing this (there may be more). One is
to use the System.Diagnostics.Process class to invoke NET USE and map the
drive that way (I have posted a sample of doing this below). The second way
is to use PInvoke to accomplish the mapped drive (I have posted a link to an
article detailing this.

I hope this helps.
--------------------

--PInvoke way
http://www.dotnet247.com/247reference/msgs/4/22781.aspx

--Process way

ProcessStartInfo pi = new ProcessStartInfo();
pi.FileName = "NET";
pi.Arguments = "USE \\<servername> /user:<username>";
Process p = new Process();
p.StartInfo = pi;
p.Start();
 
Thanks, guys I have the mapping part working now and I know how to get
to a certain file and start reading from it but how do you seek the
pointer to a certain line in a text file?
 
Back
Top