C sharp - Mapear una unidad de red con C#

 
Vista:

Mapear una unidad de red con C#

Publicado por Daniel (1 intervención) el 30/10/2008 11:02:48
Hola a todos,

¿alguien sabe cómo mapear una unidad de red desde código?

Saludos!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Mapear una unidad de red con C#

Publicado por Arturo Garcia Perez (1 intervención) el 02/04/2016 01:16:51
Dejo extracto de la classe


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
 
namespace RedSITI_Compras
{
    class Program
    {
        static void ExecuteConnect(string _Departamento)
        {
            string[] _Red = new string[4];
            if (_Departamento.ToUpper().Equals("COMPRAS"))
            {
                _Red[0] = @"net use P: \\10.2.2.1\Personal /USER:sitiver sitiver /PERSISTENT:YES";
                _Red[1] = @"net use S: \\10.2.2.1\Software /USER:sitiver sitiver /PERSISTENT:YES";
                _Red[2] = @"net use T: \\10.2.2.2\Publico /USER:Compras TeamC2015 /PERSISTENT:YES";
                _Red[3] = @"net use X: \\10.2.2.2\Compras /USER:Compras TeamC2015 /PERSISTENT:YES";
 
                for (int i = 0; i < 4; i++)
                {
                    System.Diagnostics.ProcessStartInfo procStarInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + _Red[i]);
                    procStarInfo.RedirectStandardOutput = true;
                    procStarInfo.UseShellExecute = false;
                    procStarInfo.CreateNoWindow = false;
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo = procStarInfo;
                    proc.Start();
                    string result = proc.StandardOutput.ReadToEnd();
                    Console.Write(result);
                }
            }
 
        }
 
        static void Main(string[] args)
        {
            string Depto = "COMPRAS";
            string command = string.Empty;
            Console.WriteLine("Conectado a las unidades de Red de SI-TI...");
            Console.WriteLine("Perfil: " + Depto);
 
            ExecuteConnect("COMPRAS");
 
            Console.Write("Pulse una tecla para salir");
            Console.ReadKey();
 
        }
    }
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar