Results 1 to 10 of 10

Thread: [RESOLVED] [2008] Can't find text file on C: drive

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Location
    South Wales, UK
    Posts
    14

    Resolved [RESOLVED] [2008] Can't find text file on C: drive

    I have a small app running on a windows Mobile 6 device and wrote the following to read a text file

    Code:
     Dim FILE_NAME As String = "C:\test.txt"
    
                If System.IO.File.Exists(FILE_NAME) = True Then
                    Dim objReader As New System.IO.StreamReader(FILE_NAME)
                    TextBox1.Text = objReader.ReadToEnd
                    objReader.Close()
                Else
                    MsgBox("File Does Not Exist")
    When I debug this using the "Windows Mobile 6 Professional Emulator" option I get "File Does Not Exist".

    I am reasonably sure the file name is spelt correctly - should I be specifying it as something different to "c:\" for the emulator, please?

    I have not tried it on the device itself yet.

    Any help would be appreciated.

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [2008] Can't find text file on C: drive

    Hi,
    pocket pc does not have a concept of c:\ drives, or any drives for that matter.

    If you do
    Dim FILE_NAME As String = "\test.txt"

    That is in the root folder

    "test.txt" is in the same folder as your application, and "\My Documents\test.txt" is in the My Documents folder

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Location
    South Wales, UK
    Posts
    14

    Re: [2008] Can't find text file on C: drive

    many thanks for that Pete - I suspected that it must be something like that, so was pleased to get the correct format ...

    sorry for the delay in replying but I have been having a lot of trouble getting this working .. and still it does not work - despite the fact that I have dotted files all around the place ... and even tried creating a file to see where it was created .. the following worked fine in concept - but still no file could be found. This must be some characteristic of the Emulator I feel sure..

    Code:
    Dim FILE_NAMEw As String = "\test3.txt"
    
                Dim objWriter As New System.IO.StreamWriter(FILE_NAMEw, False)
                Dim testtext As String = "this is the test"
                objWriter.WriteLine(testtext)
                MsgBox("File created - " & FILE_NAMEw)
                objWriter.Close()
    
                Dim FILE_NAME As String = "\test3.txt"
    
                If System.IO.File.Exists(FILE_NAME) = True Then
                    MsgBox("File ok - " & FILE_NAME)
                    Dim objReader As New System.IO.StreamReader(FILE_NAME)
                    TextBox1.Text = objReader.ReadToEnd
                    objReader.Close()
                Else
                    MsgBox("File Does Not Exist - " & FILE_NAME)
    I am now having a think - and read - to see if the emulator requires some different approach - I may even deploy it to the device to see if that makes a difference

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [2008] Can't find text file on C: drive

    Hi,
    the emulator should be no different.

    Have you looked on the emulator to see if the file does indeed exist?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Location
    South Wales, UK
    Posts
    14

    Re: [2008] Can't find text file on C: drive

    I did a search of the PC - C:\ drive for the file - test3.txt - and it didn't exist ? Even though it had created it - read it - and displayed the contents (see my code) according to the messagebox displays ?
    The emulator normally undoes everything - so that did not surprise me too much. But I am unsure where else to look ?

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Location
    South Wales, UK
    Posts
    14

    Re: [2008] Can't find text file on C: drive

    I have just deployed the app to the device (HP IPAQ) and it works fine - I used \my documents\test.txt as you suggested.

    It is strange that I couldn't get it working under emulation - I may just be putting the file in the wrong place - but at least I can proceed now.

    Many thanks Phil. I will wait a short while to see if there are any further comments re the emulator - but will set it as resolved tomorrow morning.

  7. #7
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [2008] Can't find text file on C: drive

    Hi,
    you need to look using explorer in the emulator.

    The emulator is the same as the device - doesn't know anything about a c:\ drive or any drive on your PC, unless you map to it as a shared folder.

    BTW - It's Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  8. #8

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Location
    South Wales, UK
    Posts
    14

    Re: [2008] Can't find text file on C: drive

    Bingo !!!

    Now I understand Pete (sorry about the name earlier)

    The emulator is a complete emulation of the device - So I use it's own File Explorer to look for the files - and there they are ... that answers all the questions ... except one (there is always one isn't there).

    To put a text file on the physical device I use ActiveSync - and explore from there - it allows me to drag and drop files at will.

    I cannot just drag and drop from within Windows to the emulator - it just won't let me - so how do I get my file - "test.txt" into the emulator - please ?

    (here's hoping this is not an obvious one that I have missed)

    many thanks for your patience and persistance ....

  9. #9
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [2008] Can't find text file on C: drive

    Hi,
    in Visual Studio, do Tools>Device Emulator Manager.

    When your emulator is running, you should see in the list it is connected. Simply right-click on the connection, and click on 'cradle' - this will run activesync and connect it. Then you can explore it just like a device, and drag and drop files

    HTH
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  10. #10

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Location
    South Wales, UK
    Posts
    14

    Re: [2008] Can't find text file on C: drive

    :-)

    Thanks very much for that ....

    I had to run ActiveSync from the PC first - to setup the connection - but I imagine that will be just the first time - it will probably run automatically from here on.

    All is now working well - and I cannot thank you enough.

    regards Lol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width