4

I copied over some code from a test app:

const string sdfPath = @"C:\WebAPIClient\WebAPIClient\bin\Debug\DBPlatypusCompactDB.sdf";
string dataSource = string.Format("Data Source={0}", sdfPath);
int countAdded = 0;

    if (!File.Exists(sdfPath))
. . .

...which works fine there; but on trying to convert it for use in the project that will run on the Windows CE device:

const string sdfPath = @"Computer\WindowsCE\\\Program Files\hhs\DBPlatypusCompactDB.sdf";            
. . .

...(this is the path I copied from Windows Explorer (the folder to which the exe is deployed, which has no subfolders)), I get "path not found" or "path not valid" or something similar.

How am I to designate the path?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

2 Answers2

7

It's not really clear what you're trying to do, so here are some general pointers:

  1. Windows CE doesn't understand relative paths. Period. So all paths must start with a backslash (\) character.
  2. "Computer" is highly unlikely to be part of the path on your device. Use Explorer on the device ansd look at the path there. What you're after is probably something like \Program Files\hhs\mydatabase.sdf
  3. Desktop paths to a device are not actual paths. They are shell plug-in trickery. A path on the PC like My Device\Program Files\foo.bar is not a path resolvable by any File APIs on the desktop. If you want to access a device file from a PC app, you must use something like RAPI to pull the file locally, then use the local copy
ctacke
  • 66,480
  • 18
  • 94
  • 155
1

if you want to run on device use this code:

const string sdfPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase + @"\FolderName\Filename.*"

but, you need to copy FolderName to device on Program File path see images folder example:

Connect to your device

Show images folder example

Ya Kutty
  • 31
  • 3
  • 1
    Welcome to Stack Overflow! When giving an answer it is preferable to give [some explanation as to WHY your answer](http://stackoverflow.com/help/how-to-answer) is the one. – Stephen Rauch Feb 02 '17 at 03:30