none
Read data from CSV file - to the Pocket PC

    Question

  •  

    hi,

     

    i need to write an application which reads data from an CSV file, to the pocket pc, with Mobile 5.0.

     

    my problem is that i don't know how to do the path to the CSV file, i'm working with the emulator.

     

    those lines throw an "Could not find file '\'C:\Cities.csv'."  exception in line 4:

     

    1.Dim objStreamReader As IO.StreamReader

    2.Dim txtDelimiter As String

    3.Dim oneLine As String

    4.Dim file As New System.IO.StreamReader("'C:\Cities.csv'")

     

    5.Private Sub open()

    6.       txtDelimiter = ","

    7.       oneLine = file.ReadLine()

    8.        While (oneLine <> "")

    9.                  oneLine = file.ReadLine()

    10.      End While

    11.End Sub

     

     

    the file is excisting, but the question is how to make themobile to get to its location.

     

    thanks...! Smile

    hani

     

     

    Sunday, September 23, 2007 4:32 PM

Answers

  • I’ve just checked my C: drive and there’s no “Cities.csv” on it. Or do you expect your device to grab it from your desktop just because it’s closer?

    Seriously, there’s no way device (or emulator - which is also a device, only simulated) can see hard drive on your desktop by letter for rather obvious reasons (like security considerations and missing host qualifier).

    If you want to read a file on device you have to copy it on to device file system and specify correct path on that file system.

    Devices don’t have driver letters and they don’t support relative paths so make sure to specify full path. Check if file actually exist using file explorer on device. Normal path looks like this:

    “\Program Files\ApplicationNameHere\FileNameHere.csv”.

    You can copy file to device manually, say, using Active Sync. Or you can add it to your VS project and configure VS to deploy it for you by setting “Build Action” to “Content” and “Copy to output directory” to “Copy Always” or “Copy if newer” as appropriate.

     

    Sunday, September 23, 2007 6:05 PM
    Moderator