Smart Device program being able to locate a text file


  • I wonder if I can get some help?

    I have a program that I've 'deployed' to a Smart Device emulator (Pocket PC SE 2003) and this program has to access a text file. I've also gotten that text file to go over to the emulator so I know it's there in the same directory as the program.

    My problem is that I don't know how to 'call' the program. I just asked for it by name (in a StreamReader call) and the error message I get states that it cannot locate the file.

    My question is how do I refer to the file so that my program can load and work with it? I've tried putting a 'slash' in front of the name but that is no help.

    Thank you very much for any help you might give me.

    Friday, May 19, 2006 6:48 AM


All replies

  • You have to specify full path of the file, just like you have to specify full address if you mailing something.

    If your text file is in the same folder as your application EXE, you can determine that location and append file name to construct full path as described here:

    Friday, May 19, 2006 7:10 PM
  • Thank you for your help. What I ended up doing was:

    Dim path As String

    path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

    Label1.Text = path 'So I can see the path

    Then I concatenated 'path' with "\TheTextFile.txt" and it worked!

    Thanks once more for helping me. I can see right away that this help forum stuff is a *very* valuable resource to have available.

    Best regards. 

    Saturday, May 20, 2006 2:59 AM