2

My program needs to read an XML file that a software vendor sent me in order to complete a process. The problem is I cannot tell the program where the file is locate!

When i publish the program and install the program it generates a random folder every time it installs Location the same folder name is always different

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

I Have figured out how to get that folder to show by doing this

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

But the program creates a second folder that it puts the XML and the ICOn file in thats randomly generated but in the same directory.

How do I get the program to look in that folder for the xml?

PLEASE HELP ME !

Ray

Enigmativity
  • 113,464
  • 11
  • 89
  • 172

2 Answers2

0

You could do this:

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()
Enigmativity
  • 113,464
  • 11
  • 89
  • 172
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
Jack Gajanan
  • 1,596
  • 14
  • 18