
Imports Imports MySql.Data.MySqlClient
Public Class Form5
Dim WenM() As String
Dim BF As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FileNema As New OpenFileDialog()
FileNema.FileName = ""
FileNema.Filter = "(*.*)|*.*"
FileNema.ShowDialog()
WenM = FileNema.FileNames
TextBox1.Text = FileNema.FileName
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If IO.File.Exists(TextBox1.Text) = False Then
MsgBox("错误,源文件不存在")
Exit Sub
End If
If IO.Directory.Exists(TextBox2.Text & "\" & TextBox3.Text) = False Then
MsgBox("错误,目标不存在")
Exit Sub
End If
'TextBox2.Text 这里的内容由form1_load 加载
Dim Fname As String
Fname = Mid(WenM(0), InStrRev(WenM(0), "\") + 1)
Dim Mubiao As String = TextBox2.Text & "\" & TextBox3.Text & "\" & Fname
' Shell("c:\windows\system32\cmd.exe /c net use \\172.16.32.110 "" /user:""")
If IO.File.Exists(Mubiao) Then
If IO.Directory.Exists(BF & TextBox3.Text) = False Then
Directory.CreateDirectory(BF & TextBox3.Text)
End If
Dim FnameF() As String = Fname.Split(".")
If Not Chaxun(Fname) Then
ver = "100001"
End If
Dim Fnamesss As String = FnameF(0) & "_" & ver & "." & FnameF(1)
(Mubiao, BF & TextBox3.Text & "\" & Fnamesss, True)
End If
Try
(TextBox1.Text, Mubiao, True)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MsgBox("文件以上传至" & TextBox2.Text & "\" & TextBox3.Text)
Form1.TextBox1.Text = Fname
Me.DialogResult = DialogResult.OK
Me.Close()
End Sub
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim files() As String = ("\\172.16.32.100\pic", "*", SearchOption.AllDirectories)
'\\172.16.32.100\pic \\172.16.32.100\data
Dim files_d() As String = ("\\172.16.32.100\data", "*", SearchOption.AllDirectories)
Dim str((files.Length - 1) + files_d.Length) As String
For i = 0 To files.Length - 1
Dim zstr() As String = files(i).Split("pic\")
str(i) = "pic\" & zstr(1).Substring(3)
Next
For i = files.Length To (files.Length - 1) + files_d.Length
Dim zzstr() As String = files_d(i - files.Length).Split("data\")
str(i) = "data\" & zzstr(1).Substring(4)
Next
Me.TextBox3.AutoCompleteCustomSource.AddRange(str)
Me.TextBox3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
Me.TextBox3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource
Try
If Not IO.Directory.Exists("config.txt") Then
'MsgBox("错误,目标不存在")
Dim sr() As String = File.ReadAllLines("config.txt")
BF = sr(6)
Else
BF = "D:\"
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Dim mycon
Dim ver
'查询的东西是否存在
Function Chaxun(ByVal name_add As String)
Dim myDate As MySqlDataReader
Dim Constr As String = "server=" & Form1.TextBox3.Text & ";User Id=" & Form1.TextBox4.Text & ";password=" & Form1.TextBox5.Text & ";Persist Security Info=True;database=" & Form1.TextBox7.Text & ";"
mycon = New MySqlConnection(Constr)
Dim sql As String = "select * from resource_version where resource_name='" & name_add & "'"
'MsgBox(sql)
Dim cmd As New MySqlCommand(sql, mycon)
mycon.open()
myDate = cmd.ExecuteReader()
Try
Do While myDate.Read()
ver = myDate(1)
mycon.Close()
Return True
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
mycon.Close()
Return False
End Function
End Class
第一次打开这个界面,没有任何问题,第二次打开报错
找不到config.txt文件,寻找的位置在之前选择文件的目录