……
Else
For Each File As String In FileSys.GetFiles(dir)
dim f2 as string = File.Replace("F:\项目F6\", "G:\项目G7\")
If FileSys.FileExists(f2) = False Then
FileSys.CopyFile(File, f2)
End If
Next
End If
Dim path As String = e.Form.Controls("ComboBox1").Text '指定文件夹路径,如:"F:\项目F6"
Dim str As String = e.Form.Controls("TextBox1").Text '查找文件名内容,这里可查文件名部分内容
Dim f As String = ""
For Each file As String In FileSys.GetFiles(path) '遍历指定路径文件夹目录所有文件
If FileSys.GetName(file).StartsWith(str) Then '逐个文件名判断
f = file
Exit For
End If
Next
If f > "" Then
Messagebox.Show("文件已经存在!", "提示")
System.Diagnostics.Process.Start("Explorer", " /select," & f & " ")
Else
Messagebox.Show("文件不存在或已经被删除!", "提示")
End If
老师, 文件夹中有文件名如"Word 1文档"、"Word 文档3"等, 我输入"文档"就差不到, 能不能输入文件名部分内容就可模糊查到?
Dim path As String = e.Form.Controls("ComboBox1").Text '指定文件夹路径,如:"F:\项目F6"
Dim str As String = e.Form.Controls("TextBox1").Text '查找文件名内容(可查文件名部分内容)
Dim f As String = ""
For Each file As String In FileSys.GetFiles(path) '遍历指定路径文件夹目录所有文件
If FileSys.GetName(file).Contains(str) Then '用Contains 判断字符串是否包含一个给定的子字符串
f = file
Exit For
End If
Next
If f > "" Then
Messagebox.Show("文件已经存在!", "提示")
System.Diagnostics.Process.Start("Explorer", " /select," & f & " ")
Else
Messagebox.Show("文件不存在或已经被删除!", "提示")
End If
For Each file As String In FileSys.GetFiles(path) '遍历指定路径文件夹目录所有文件
If FileSys.GetName(file).Contains(str) Then '用Contains 判断字符串是否包含一个给定的子字符串
f = f & ";" & file
End If
Next
蓝老师,我试了一下,这个代码,没指向指定文件夹的文件,还有问题