473,241 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Map Network Drive

How can I have my network drive in my code.. Like for example X to \\pc1 and
have to type password

Thanks

Nov 20 '05 #1
4 4475
You can use the NetAPI to do so. Chris Dunaway sent me a C# class that had
all of the wrappers for the most common API's but I have it at home... =(

Maybe he can post it here or email it to you.

-cJ

"Carlos" <cp@swa.com> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
How can I have my network drive in my code.. Like for example X to \\pc1 and have to type password

Thanks

Nov 20 '05 #2
Try

System.Diagnostics.Process.Start("net", "use h: \\tower1\newpublic")

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try

Regards OHM

"Carlos" <cp@swa.com> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
How can I have my network drive in my code.. Like for example X to \\pc1 and have to type password

Thanks

Nov 20 '05 #3
* "Carlos" <cp@swa.com> scripsit:
How can I have my network drive in my code.. Like for example X to \\pc1 and
have to type password


Sure you had a look here?

<URL:http://groups.google.de/groups?as_q=dotnet+map+network+drive+-herfried>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Hi Carlos,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to add a map network in
VB.NET.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

We can use the WNetAddConnection2 API, here goes the code snippet.

<StructLayout(LayoutKind.Sequential)> _
Class NETRESOURCE
Public dwScope As Integer
Public dwType As Integer
Public dwDisplayType As Integer
Public dwUsage As Integer
Public LocalName As String
Public RemoteName As String
Public Comment As String
Public Provider As String
End Class 'NETRESOURCE
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias
"WNetAddConnection2A" (ByVal netResource As NETRESOURCE, ByVal password As
[String], ByVal Username As [String], ByVal Flag As Integer) As Integer
Sub Main()
Dim myNetResource As New NETRESOURCE
myNetResource.dwScope = 2 'RESOURCE_GLOBALNET
myNetResource.dwType = 1 'RESOURCETYPE_DISK
myNetResource.dwDisplayType = 3 'RESOURCEDISPLAYTYPE_SHARE
myNetResource.dwUsage = 1 'RESOURCEUSAGE_CONNECTABLE
myNetResource.LocalName = "P:"
myNetResource.RemoteName = "\\sha-dds-01\Products"
myNetResource.Provider = Nothing
Dim ret As Integer = WNetAddConnection2(myNetResource, Nothing,
Nothing, 0)
End Sub
For detailed information about WNetAddConnection2 please refer to the link
below.
WNetAddConnection2
http://msdn.microsoft.com/library/de...us/wnet/wnet/w
netaddconnection2.asp
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
2
by: giloosh99 | last post by:
Hello, Im grabbing tables via VB code using visual foxpro ODBC drives. The tables directory is in a mapped network drive. The code works fine and does the job, however if the computer is idle for...
5
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a...
1
by: brian.oneil2 | last post by:
Is there a way to install this onto a network file share and allow a team to access it? I would say share a CD from a networked CD drive, but there are multiple CD's that would have to be inserted....
8
by: Lam | last post by:
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,...
5
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
14
by: frostalicious | last post by:
Used VB.NET (on my client PC) to convert VB6 executable to .NET executable. Placed the .exe file on a network drive on my server. From client, ran .NET Wizards "Trust an Assembly" to make the...
2
by: .Net Believer | last post by:
I using the routine below to copy file to a network drive for a regular backup process. Before calling this routine I using another function to check the presence of the LAN connection and the...
3
by: Barry Flynn | last post by:
Hi I am working with a VB 2005 program which has been converted from VB6. It writes data out to a flat file, with code like the following line WriteLine(riFileNo, "Hist", lsAssetID,...
10
by: =?Utf-8?B?Z3JlYXRiYXJyaWVyODY=?= | last post by:
Sorry about that previous one. I pressed enter too early. How does one go about mapping a network drive in C#. i know you use MapNetworkDrive in scripting languages, but i'm not sure how to do it...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.