我遇到此代码的问题,将Driver.Name与我资源中的字符串进行比较,如: 如果Driver.Name =“D:\”然后做一些事情,这是我的代码:
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives()
If drive.DriveType = DriveType.Fixed Then
If drive.IsReady = True Then
' this is the list in my resource
'"D:\"|"E:\"|"F:\"|"G:\"|"H:\"|"L:\"|"K:\"|"M:\"|"O:\"|
For Each word As String In My.Resources.String1.Split(CChar("|"))
If word.ToString.Contains(drive.Name) Then
MsgBox("One Driver Found")
Else
MsgBox("No Driver Found")
End If
Next
End If
End If
Next
End Sub
End Class
答案 0 :(得分:0)
尝试更改资源字符串
从此
'"D:\"|"E:\"|"F:\"|"G:\"|"H:\"|"L:\"|"K:\"|"M:\"|"O:\"|
到此
'"D:\|E:\|F:\|G:\|H:\|L:\|K:\|M:\|O:\|"