搜索字符串 - 路径中的非法字符 [英] Search string - illegal chars in path

查看:46
本文介绍了搜索字符串 - 路径中的非法字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个搜索字符串.

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?

网络上的路径是:

\\192.168.0.2\shares\be\BERTHOUD\BA 390683 L\PROD\BA390683 L - PP. DECOMPOSITION 160630.pdf

numeclient函数代码为:

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

r 和 codnumeric 代码是:

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)

textbox4 包含这样的字符串:BA390683 L

The textbox4 contains string this form: BA390683 L

推荐答案

你可以先简化你的代码,在调用函数时加上括号:

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"

其次,通过调试器检查构成路径或扩展名的值:functiicomune.numeclientr编码数字

and second, check the values which compose the path or extension through your debugger : functiicomune.numeclient r codnumeric

这篇关于搜索字符串 - 路径中的非法字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆