473,396 Members | 1,738 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,396 software developers and data experts.

map 2 Dirves

Here is my code, and I cannot get it to work.

I have files that I get from two map drives X and Y. So when I start my pc,
I have to go to explorer and manly map them every time, before I can get the
files on the drives.

Can someone please look at my code, a tell me were do I need to put the drive
info, userid, password in for each drive.
This part is working.

Private Sub Import_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Import.Click

Dim path1 As String = "Y:\Busres.txt"
Dim path2 As String = "X:\Smeyl.txt"

If File.Exists(path1) AndAlso File.Exists(path2) Then
Cls_MessageBbox.Show("All files were importerd", "",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

End If

If (Not File.Exists(path1)) Then
Cls_MessageBbox.Show(path1 & " leër is nie op Busres Server nie."
& vbNewLine & vbNewLine & "Maak seker Program het geloop op Server", "",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
My.Computer.FileSystem.MoveFile("Y:\BUSRES.TXT", "C:\Werk\Busres.
txt", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.ThrowException)
End If

If (Not File.Exists(path2)) Then
Cls_MessageBbox.Show(path2 & " leër is nie op Busres Server nie."
& vbNewLine & vbNewLine & "Maak seker Program het geloop op Server", "",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
My.Computer.FileSystem.MoveFile("X:\SMEYL.TXT", "C:\Werk\SM.txt",
FileIO.UIOption.AllDialogs, FileIO.UICancelOption.ThrowException)
End If

End Sub


This new code and I am not sure how it works. and it must work with my first
part of code


Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias
"WNetAddConnection2A" (ByRef lpNetResource As NETRESOURCE, ByVal lpPassword
As String, ByVal lpUserName As String, ByVal dwFlags As Integer) As Integer
Public Declare Function WNetCancelConnection2 Lib "mpr" Alias
"WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Integer,
ByVal fForce As Integer) As Integer
Public Structure NETRESOURCE
Public dwScope As Integer
Public dwType As Integer
Public dwDisplayType As Integer
Public dwUsage As Integer
Public lpLocalName As String
Public lpRemoteName As String
Public lpComment As String
Public lpProvider As String
End Structure
Public Const ForceDisconnect As Integer = 1
Public Const RESOURCETYPE_DISK As Long = &H1

Public Function MapDrive(ByVal DriveLetter As String, ByVal UNCPath As
String) As Boolean

Dim nr As NETRESOURCE
Dim strUsername As String
Dim strPassword As String

nr = New NETRESOURCE
nr.lpRemoteName = UNCPath
nr.lpLocalName = DriveLetter & ":"
strUsername = Nothing '(add parameters to pass this if necessary)
strPassword = Nothing '(add parameters to pass this if necessary)
nr.dwType = RESOURCETYPE_DISK

Dim result As Integer
result = WNetAddConnection2(nr, strPassword, strUsername, 0)

If result = 0 Then
Return True
Else
Return False
End If
End Function

Aug 22 '08 #1
0 624

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

Similar topics

5
by: Kevin Joseph | last post by:
I have written a Perl script to modify some files over the network. All PCs are Win2k. Most of the files reside on a share in the form of \\server\share_name. Some of the files are on dirves in the...
13
by: Just Me | last post by:
The following almost works. The problem is Marshal.PtrToStringAuto seems to terminate at the first null so I don't get the full string. Any suggestions on how to fix this? Or how to improve the...
0
by: gh | last post by:
I am looking for a web file manager, that will allow me to specify the folders on the web server, I want user to be able to upload files into from their local dirves. The user will also need to be...
3
by: mike_dba | last post by:
I have read that raw i/o on Linux has been depricated and support for it might be removed from future kernal releases. I am trying to assess what impact this has. My current db was built on...
6
by: nethajireddy | last post by:
hi can any one help me if i ping from my server to local lan it's pinging but if i use to access one drive from server is not possible
1
by: VEnkatramasamy | last post by:
Hi to Every one One of my prgram expects drive letter for validation purpose(which can't be negotiated),while hadling the mappeddrives no problem with any OS except Windows vista, it returns the...
0
by: miztaken | last post by:
Hi i was developing a C# code using wtsapi32.dll. I was developing a wrapper class. I am now stuck in a case in which i have to get the list of client;s disk drives on the terminal application. ...
4
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a multiline RichTextBox that I use for data logging. I'm concerned about how the AppendText method reacts when over time the maximum number of characters have been added. Do the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.