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")

しかし、プログラムは 2 番目のフォルダーを作成し、XML と ICOn ファイルをランダムに生成された同じディレクトリに配置します。

プログラムがそのフォルダーでxmlを検索するようにするにはどうすればよいですか?

私を助けてください !

レイ

4

2 に答える 2

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 に答える
0

フィルターですべてのファイルのリストを取得する

    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 に答える