如何检查文件是否位于 Windows 网络共享上?

发布于 2024-12-10 20:01:52 字数 143 浏览 1 评论 0原文

我需要检查文件是否通过网络访问。我正在检查的值 GetFileAttributes("\\\\Foo\\Bar\\foobar.txt") & FILE_ATTRIBUTE_OFFLINE 但它从未设置。实现这一目标的更稳健的方法是什么?

I need to check if files are accessed through the network. I'm checking the value of
GetFileAttributes("\\\\Foo\\Bar\\foobar.txt") & FILE_ATTRIBUTE_OFFLINE but it's never set. What is the more robust way to achieve this ?

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

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

发布评论

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

评论(2

美人如玉 2024-12-17 20:01:52

脱机是一种特殊的文件状态,您也可以将其设置为网络文件,但必须自行设置。并非每个脱机文件都会自动标记为脱机使用。我认为资源管理器上甚至有一个用于离线文件的特殊覆盖图标(黑色时钟?)。

我认为使用 PathIsNetworkPath() 您可以检查文件是否在网络上。

Offline is a special file status that you can also set to on network files but you have to set it yourself. Not every offline file is automatically marked for offline use. I think there even is a special overlay icon on explorer for offline files (a black clock?).

I think that with PathIsNetworkPath() you can check that the file is on the network.

二手情话 2024-12-17 20:01:52

调用 GetVolumePathName,然后调用 GetDriveType。

如果指定了网络共享,则 GetVolumePathName 返回 GetDriveType 返回 DRIVE_REMOTE 的最短路径。

call GetVolumePathName and then GetDriveType.

If a network share is specified, GetVolumePathName returns the shortest path for which GetDriveType returns DRIVE_REMOTE.

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