问题
I have this search string.
Dim files As String() = IO.Directory.GetFiles("\\192.168.0.2\shares\be\" & functiicomune.numeclient & "\" & r & " " & codnumeric & "*" & "\" & "PROD\", "*" & codnumeric & "*" & "DECOMPOSITION" & "*" & ".pdf")
I get illegal characters in path and i dont know why. Can someone provide a hint?
The path on the network is:
\\192.168.0.2\shares\be\BERTHOUD\BA 390683 L\PROD\BA390683 L - PP. DECOMPOSITION 160630.pdf
The numeclient function code is:
Public Shared Function numeclient()
Dim codclient As String = Form1.TextBox4.Text.Substring(0, 2)
Dim r As String
Select Case codclient
Case "BA"
r = "BERTHOUD"
Case "CN"
r = "CARUELLE"
Case "TT"
r = "TECNOMA"
Case "PR"
r = "PRECICULTURE"
Case "KR"
r = "KREMLIN"
End Select
Return r
End Function
The r and codnumeric code is:
Dim rgx As New Regex("[^0-9]")
Dim codnumeric As String = rgx.Replace(TextBox4.Text, "")
Dim r As String = TextBox4.Text.Substring(0, 2)
The textbox4 contains string this form: BA390683 L
回答1:
You could simplify first your code, and add parenthesis when calling the function :
Dim files As String() = IO.Directory.GetFiles("\\192.168.0.2\shares\be\" & functiicomune.numeclient() & "\" & r & " " & codnumeric & "*PROD\","*" & codnumeric & "*DECOMPOSITION*.pdf"
and second, check the values which compose the path or extension through your debugger :
functiicomune.numeclient
r
codnumeric
来源:https://stackoverflow.com/questions/39716681/search-string-illegal-chars-in-path