0

我需要递归地在手持设备上搜索设备上任何遵循某种模式的文件(例如“鸭嘴兽.XML”)。

要将设备的根目录传递给我的目录遍历方法,我是传递“\”还是别的什么?

在 Windows 资源管理器中,设备是“J:\” - 但我知道这行不通,因为它不会为每个人都映射到 J。

Windows 资源管理器中设备的全名类似于:

Duckbill (\\LEXINGTON\dev\Xmen\Miguel\Installs) (J:)

...但类似地,每个人的设备都会有不同的名称,所以这是行不通的。

那么根文件夹是用“\”指定的,还是我可以调用一些方法来获取该指示符,例如Environment.SpecialFolder.Startup或...???

更新

更具体地说,对于我的情况,如果 Windows 资源管理器说有问题的文件夹是“ Computer\Goliath's Device\Application\ccr ”,那么我需要以编程方式指定该文件夹:“ \Application\ccr ”吗?

更新 2

以下代码导致 FileNotFound 异常,然后 .exe 在手持设备上崩溃:

string clientVer = HHSUtils.GetFileVersion(@"\\Platypus.exe");

public static string GetFileVersion(string filePath)
{
        const int VERSION_DEPTH = 4;
        var version = NativeFile.GetFileInfo(filePath);
        return version.Version.ToString(VERSION_DEPTH);
}

更新 3

具有以下内容:

string serNum = User.getSerialNo();
string clientVer = DuckbillUtils.GetFileVersion("\\Application\\ccr\\Platypus.exe");
MessageBox.Show(string.Format("serial num == {0}; clientVer == {1}", serNum, clientVer));

...我得到:

序列号 == ; 客户端版本 == ; Win32异常

而具有以下内容:

string clientVer = DuckbillUtils.GetFileVersion(@"\\Application\ccr\Platypus.exe");

(其他代码行相同;逐字字符串唯一的区别)

...我得到:

序列号 == ; 客户端版本 == ; FileNotFoundException

更新 4

我在这里找到了一些很好的信息,并基于那里的代码:

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

...这就是它为我的 .exe 显示的内容:

“\程序文件\HHS\HHS.exe”

...然后我尝试在(在不同的子文件夹中,但共享相同的祖父文件夹)检查“表亲”exe:

@"\\Program Files\\LocateNLaunch\\LocateNLaunch.exe"

...但是 GetFileVersion() 方法没有给我任何东西。

无论如何,我真正想要检查的文件(对于它的版本信息)在,而不是文件夹本身,但是由于缺乏知识将称为“子设备”(我不知道术语是什么,但是在 Windows Explorer 设备分为“子设备”或“超级文件夹”,它们下面有文件夹)。如何指示/指定您想要访问的内容?我的 .exe 在一个“子设备”中,而我需要读取(并可能替换)其版本信息的 .exe 在另一个“子设备”中...

如果不清楚,这里有一个尖叫声:

enter image description here

So how can I point my code to that file (HHSetup.exe) beneath the Application subdevice\sscs folder?

UPDATE 5

With this code:

string clientVer = HHSUtils.GetFileVersion(@"\Application\sscs\HHSetup.exe");

...I still get an empty string from that call, followed by a Win32Exception.

4

2 回答 2

1

The device name is irrelevant, it's purely a Explorer Shell Extension trick. On the device itself, the root is always \. All paths must be fully qualified from that root.

I'd recommend doing some testing before getting the native version info. Something like:

if(!File.Exists(path))
{
    // don't try, report an error or whatever
}
else
{
    var version = GetFileInfo(path);
}

or

var fi = new FileInfo(path);
if(!fi.Exists)
{
    // don't try, report an error or whatever
}
else
{
    var version = GetFileInfo(fi.FullName);
}
于 2014-03-04T22:37:58.057 回答
1

Yes, in CE, the root of all storage is \. See here for details: Understanding the File System Architecture in Windows CE .NET. In particular:

The Windows CE .NET file system is a flexible modular design that allows for custom file systems, filters, and a variety of different block device types. The file systems and all file-related APIs are managed by the FileSys.exe process. This module implements the object store and Storage Manager (we'll look into the object store in a little bit) and unifies all of the file systems into a single system under one root, "\". In Windows CE .NET, all files and file systems exist in a single namespace starting from "\" as the root. All files are identified with a unique path from the root in a hierarchal tree.

Devices can be mounted to the root filesystem, and the mount names are identified in the registry, under HKEY_LOCAL_MACHINE\System\StorageManager\Profiles.

于 2014-03-05T13:57:53.333 回答