Dim path As String = e.Form.Controls("ComboBox1").Text
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
f = file & " ; " & f
msgbox(f) '加上这句提示,就知道有几个文件名了
End If
Next
If f > "" Then
Messagebox.Show("文件已经存在!", "提示")
System.Diagnostics.Process.Start("Explorer", " /select," & f & " ") '如果存在,将鼠标移到该文件上选中该文件。(现在这里出问题,代码执行完成后,鼠标不指向该文件了)
Else
Messagebox.Show("文件不存在或已经被删除!", "提示")
End If
请老师看一下如何解决鼠标指向问题
[此贴子已经被作者于2024/6/6 16:49:48编辑过]
这个没有办法,
Process.Start这种用法只能选中一个文件,f变量是多文件的组合,无法识别
好果有几个文件,能不能选择任意一下,最初一个,最后一个,都可以,这样行吗
很基本的功能啊!
Dim f As String = ""
Dim f2 As String = ""
For Each file As String In FileSys.GetFiles(path)
If FileSys.GetName(file).Contains(str) Then
f = file & " ; " & f
f2 = file
msgbox(f) '加上这句提示,就知道有几个文件名了
End If
Next
Dim path As String = e.Form.Controls("ComboBox1").Text
Dim str As String = e.Form.Controls("TextBox1").Text
Dim f As String = ""
Dim r As String = ""
For Each file As String In FileSys.GetFiles(path)
If FileSys.GetName(file).Contains(str) Then '用Contains 判断字符串是否包含一个给定的子字符串
f = file & " ; " & f
Msgbox(f) '加上这句提示,就知道有几个文件名了
r = file
End If
Next
If r > "" Then
System.Diagnostics.Process.Start("Explorer", " /select," & r & " ") '如果存在,将鼠标移到该文件上选中该文件
Else
Messagebox.Show("文件不存在或已经被删除!", "提示")
End If
刚好我也写了,试用了不错,谢谢老师
For Each File As String In FileSys.GetFiles("F:\项目F6\项目F1")
Dim ext As String = FileSys.FileName(file).SubString(FileSys.FileName(file).LastIndexof(".") + 1) '获得文件后缀名
Select Case ext
Case "doc"
Dim i As Integer = 1
For Each File As String In FileSys.GetFiles("F:\项目F6\项目F1")
If FileSys.FileExists("F:\项目F6\项目F1" & Format(i, "000") & ".doc") = False Then
FileSys.RenameFile(file, Format(i, "000") & ".doc")
End If
i += 1
Next
End Select
Next
窗口按钮代码,请老师修改一下代码