Search string - illegal chars in path

房东的猫 提交于 2019-12-20 07:21:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!