Mapping a Drive

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 -
 
G

Guest

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();
 
J

John Smith

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?
 

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