dimanche 10 mai 2015

How to read 2nd level sub-directory text file in vb.net

I have a little program which is supposed to read text from a text file. The text file is contained in a sub-directory as follows:

Customer > Sub-directory 1 > Sub- directory 2 > Text file

The code I am using is:

Dim ti = New DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Customers\" & TextBox1.Text))

Dim du As String = Path.Combine(ti.FullName, TextBox2.Text, TextBox3.Text + ".txt")
Dim ObjectReader As New System.IO.StreamReader(du)
‘Continue and execute the rest of the code

Where:

  • TextBox1 = Name of the Customer
  • TextBox2 = Name of product
  • TextBox3 = Reference

The error I am getting is:

“Could not find a part of the path 'C:\Users\Mark\Desktop\Customers\Biscuits\Reference.txt”.

I notice that the Name of the Customer is not being searched, hence the error. Please how do I rectify this? I am using Visual Basic 2010 Express. Thank you.

Aucun commentaire:

Enregistrer un commentaire