Imports System.IO
Public Class Literature
Dim Pad1 As String = "J:\General\Literature\Actual literature\xxx\BE I & O"
Dim Pad2 As String = "J:\General\Literature\Actual literature\xxx\I&O's"
Dim Pad3 As String = "J:\General\Literature\Actual literature\xxx\MII bulletins + I & Os"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not System.IO.Directory.Exists(Pad1) Then
MsgBox("Het pad bestaat niet." & vbCrLf & Pad1, MsgBoxStyle.Critical, Me.Text)
Exit Sub
End If
If Not System.IO.Directory.Exists(Pad2) Then
MsgBox("Het pad bestaat niet." & vbCrLf & Pad2, MsgBoxStyle.Critical, Me.Text)
Exit Sub
End If
If Not System.IO.Directory.Exists(Pad3) Then
MsgBox("Het pad bestaat niet." & vbCrLf & Pad2, MsgBoxStyle.Critical, Me.Text)
Exit Sub
End If
FillCheckedListBox()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim PathToCopyFrom As String
Dim PathToCopyTo As String
PathToCopyTo = "J:\Orders\SM" & TextBox1.Text & "\Documentation"
If Not System.IO.Directory.Exists(PathToCopyTo) Then
MsgBox("SM pad bestaat niet." & vbCrLf & PathToCopyTo, MsgBoxStyle.Critical, Me.Text)
Exit Sub
End If
For i As Integer = 0 To CheckedListBox1.Items.Count - 1
If Me.CheckedListBox1.GetItemCheckState(i) = CheckState.Checked Then
PathToCopyFrom = Pad1 & "" & Path.GetFileName(CheckedListBox1.Items(i))
If System.IO.File.Exists(PathToCopyFrom) Then
PathToCopyTo = PathToCopyTo & Path.GetFileName(CheckedListBox1.Items(i))
My.Computer.FileSystem.CopyFile(PathToCopyFrom, PathToCopyTo)
Else
PathToCopyFrom = Pad2 & "" & Path.GetFileName(CheckedListBox1.Items(i))
PathToCopyTo = PathToCopyTo & Path.GetFileName(CheckedListBox1.Items(i))
My.Computer.FileSystem.CopyFile(PathToCopyFrom, PathToCopyTo)
End If
Else
PathToCopyFrom = Pad3 & "" & Path.GetFileName(CheckedListBox1.Items(i))
PathToCopyTo = PathToCopyTo & Path.GetFileName(CheckedListBox1.Items(i))
My.Computer.FileSystem.CopyFile(PathToCopyFrom, PathToCopyTo)
End If
PathToCopyFrom = ""
PathToCopyTo = "J:\Orders\SM" & TextBox1.Text & "\Documentation"
Next
End Sub
Private Sub FillCheckedListBox()
Dim fileNames As Object
Dim Pad As String
Dim i As Integer
CheckedListBox1.Items.Clear()
For i = 1 To 3
Pad = IIf(i = 1, Pad1, Pad2, Pad3)
Try
fileNames = My.Computer.FileSystem.GetFiles(Pad, FileIO.SearchOption.SearchTopLevelOnly, "*.pdf")
Catch e As Exception
MsgBox(e.Message.ToString, MsgBoxStyle.Critical)
Exit Sub
End Try
For Each fileName As String In fileNames
CheckedListBox1.Items.Add(Path.GetFileName(fileName))
Next
Next
End Sub
Private Sub CheckedListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CheckedListBox1.SelectedIndexChanged
End Sub
End Class
is een beetje aangepast(copy)
zit toch ergens een foutje in nog :s hij vind het 3de pad niet