2

我的程序需要读取软件供应商发送给我的 XML 文件才能完成流程。问题是我无法告诉程序文件所在的位置!

当我发布程序并安装程序时,它每次安装时都会生成一个随机文件夹位置相同的文件夹名称总是不同的

C:\Users\Ray\AppData\Local\Apps\2.0\6ZNVVG8V.C6O\0MELQPL9.LCB\lol-..tion_531c8308fa0ff83d_0001.0000_5a2aee0cd0a667c1

我已经想出了如何通过这样做来显示该文件夹

Dim resourcePath As String = _
    System.IO.Path.GetFullPath(My.Resources.ResourceManager.BaseName)
Dim rIndex As Integer = resourcePath.LastIndexOf("\")
resourcePath = resourcePath.Substring(0, rIndex)
Dim filePath As String = System.IO.Path.Combine(resourcePath, "Client.xml")

但是该程序创建了第二个文件夹,它将 XML 和 ICOn 文件放在随机生成的但在同一目录中。

如何让程序在该文件夹中查找 xml?

请帮我 !

射线

4

2 回答 2

0

get list of all files by filter

    lblPaymentMode.Location = New Point(lblDate.Right - lblPaymentMode.Width, lblPaymentMode.Location.Y)
    Dim mFiles() As String = Directory.GetFiles("Path of folder", "*.xml", SearchOption.AllDirectories)
    For i As Integer = 0 To mFiles.Count - 1
        Debug.Print(mFiles(i)) 'print name and path of of each file
    Next
于 2012-10-25T11:21:40.570 回答
0

你可以这样做:

Dim query = _
    From d In System.IO.Directory.GetDirectories(resourcePath)
    Let f = New FileInfo(System.IO.Path.Combine(d, "Client.xml"))
    Where f.Exists
    select f.FullName

Dim filePath = query.FirstOrDefault()
于 2012-10-25T02:34:11.967 回答