我该如何解决这个“找不到路径"的问题?错误? [英] How can i fix this "Path not found" error?

查看:40
本文介绍了我该如何解决这个“找不到路径"的问题?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何解决这个移动应用开发问题?

How can i solve this mobile application development problem?

连接到数据库时

dataSource = \\..datafile.sdf

我收到此错误

找不到路径"

我正在使用 serviceCE dll 进行数据访问.

I am using serviceCE dll for data access.

推荐答案

您输入的路径是相对路径.Windows CE/Mobile 不支持相对路径.

The path you you have typed it is a relative path. Windows CE/Mobile does not support relative paths.

因此,由于在 Windows Mobile 设备上没有当前目录的概念,如何定位仅知道相对路径的资源?.Net 程序始终可以访问组成它的模块(通常一个 .Net 组件由一个打包在 DLL 或 EXE 文件中的模块组成).以下行将返回当前正在执行的程序集的绝对路径.

It follows that since there is no concept of a current directory on a Windows Mobile device how would one locate a resource for which only a relative path is known? A .Net program always has access to the modules of which it is composed (usually a .Net component is composed of one module packaged in a DLL or EXE file). The following line will return the absolute path to the currently executing assembly.

string modulePath = this.GetType().Assembly.GetModules()[0].FullyQualifiedName;

string modulePath = this.GetType().Assembly.GetModules()[0].FullyQualifiedName;

多一点代码你就可以得到你的程序运行的目录

with a little more code you can get the directory in which your program is running

Path.GetDirectoryName(this.GetType().Assembly.GetModules()[0].FullyQualifiedName)

Path.GetDirectoryName(this.GetType().Assembly.GetModules()[0].FullyQualifiedName)

使用该信息,您可以为您的资源构建正确的路径字符串.

Using that information you can build a proper path string to your resource.

注意:如果您使用本机 APIS 进行开发,请使用以下内容:GetModuleFileName(GetModuleHandle(NULL), pszFullPath, MAX_PATH);

note: If you are developing using the native APIS use the following: GetModuleFileName(GetModuleHandle(NULL), pszFullPath, MAX_PATH);

这篇关于我该如何解决这个“找不到路径"的问题?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆