我应该使用什么来代替 Directory.SetCurrentDirecory?

发布于 2024-09-29 16:25:01 字数 374 浏览 1 评论 0原文

我有一个多环境程序,可以在 Windows CE 机器、普通 PC 和 Windows Mobile 上运行。 我正在使用数据库和文件。 由于 Windows CE,我需要在文件使用之前使用 Directory.GetCurrentDirectory() 函数,然后将当前目录(使用 Directory.SetCurrentDirectory() 函数)重置回旧目录,因为一旦我执行 I\ O 才能继续使用 DB。 由于 Windows Mobile 不支持此功能,因此在运行时会抛出异常“NotSupporetedException”。 我可以使用任何函数来代替这个函数来解决我的问题吗? 或者我可以通过什么方式在运行时检查应用程序运行的环境,并且如果应用程序在移动设备上运行,则不使用此功能?

请帮忙, 提前致谢。

i have a multi environment program that runs on windows ce machines, regular pc and windows mobile.
I am using a database and files.
because of the windows CE i need to use the Directory.GetCurrentDirectory() func before the file use and then reset the current directory (using the Directory.SetCurrentDirectory() func) back to the old one because it changes once i do the I\O in order to continue using the DB.
because the windows mobile does not support this functions there is an exception thrown during runtime a "NotSupporetedException".
any functions that i could use instead of this that should fix my problem?
or any way i can check during runtime what environment the application is running on and not use this functions if the application runs on mobile?

please help,
thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巨坚强 2024-10-06 16:25:01

我不完全理解你的目录问题,但你当然可以检查你在运行时所在的平台:

if (Environment.OSVersion.Platform == PlatformID.WinCE)
{
    ...
}
else
{
    ...
}

I don't fully understand your directory problem, but you can certainly check which platform you're on at runtime:

if (Environment.OSVersion.Platform == PlatformID.WinCE)
{
    ...
}
else
{
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文