当路径不包含驱动器号时,如何告诉编译器路径是绝对路径

How to tell the compiler a path is absolute, when the path doesn't contain a drive letter

我正在构建一个 windows 应用程序,它可以在相机(可移动设备)上查看图片而无需将它们复制到磁盘。

大多数通过 USB 连接的相机的问题是它们的路径是相对于 MyComputer 的,这是一个虚拟路径,因此不包含驱动器号(参见 C:\)。

使用 "Computer\[Camera Name]\Removable storage\AnotherDirectory\" 作为路径使编译器认为我使用的是相对路径: ...\Project\bin\Release\Computer\[摄像机名称]\可移动storage\AnotherDirectory\

我在 Using FolderBrowserDialog on a Removable Device / Removable storage 上发现了一个先前的问题,但我不习惯 COM shell 接口,想知道是否有一种方法可以告诉编译器给定路径是绝对路径?

更新

回答理查兹关于如何阅读图片的问题,

首先我按顺序收集所有jpg的路径。 然后我将该序列映射到下面的函数:

let loadPic path= 
    let bitmap = new BitmapImage()
    if System.IO.File.Exists path then
        bitmap.BeginInit()
        bitmap.UriSource <- Uri(path)
        bitmap.CacheOption <- BitmapCacheOption.OnLoad
        bitmap.EndInit()
    bitmap

生成一系列位图,然后可以查看这些位图。

它们没有被枚举为磁盘。这是不同的东西。

试试这个:

https://github.com/geersch/WPD/blob/master/src/part-3/README.md

这个有关于如何访问 MTP 设备的代码示例:

https://bitbucket.org/derekwilson/podcastutilities/src/b18a9926c1dcbfb884b34b9865ebaec96abfdb82/PodcastUtilities.PortableDevices/?at=default

希望对您有所帮助!