SpecialFolder.Desktop 和 SpecialFolder.DesktopDirectory 之间有什么区别?

发布于 2024-10-31 17:06:59 字数 934 浏览 3 评论 0原文

我对这两个特殊文件夹之间的差异感到困惑。

这是一个代码片段,它写入了每个的输出,但它们输出相同的内容。

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string pathTwo = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

Console.WriteLine(path);
Console.WriteLine(pathTwo);

Console.ReadKey();

根据 MSDN 文档(针对 .NET 1.1):

桌面
逻辑桌面而不是物理文件系统位置。

桌面目录
用于在桌面上物理存储文件对象的目录。不要将此目录与桌面文件夹本身混淆,桌面文件夹是一个虚拟文件夹。

当它说逻辑桌面而不是物理文件系统位置时,这是什么意思?另外,简单来说什么是虚拟文件夹

在较新的 .NET 4 版本中 文档,我注意到他们完全删除了Desktop,只留下了DesktopDirectory。 这是为什么呢?

I'm confused about the differences between these two special folders.

Here's a code snippet that writes the output of each, but they output the same thing.

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string pathTwo = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

Console.WriteLine(path);
Console.WriteLine(pathTwo);

Console.ReadKey();

According to the MSDN documentation (for .NET 1.1):

Desktop
The logical Desktop rather than the physical file system location.

DesktopDirectory
The directory used to physically store file objects on the desktop. Do not confuse this directory with the desktop folder itself, which is a virtual folder.

What does it mean when it says the logical Desktop rather than the physical file system location? Also, what is a virtual folder in simple terms?

In the newer .NET 4 version of the documentation, I noticed that they removed the Desktop entirely and only left DesktopDirectory.
Why is this?

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

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

发布评论

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

评论(2

你是暖光i 2024-11-07 17:06:59

原始问题的答案

目录是文件系统中的一个位置。文件夹是 shell 命名空间中的一个位置。目录是一种文件夹。虚拟文件夹不一定由目录支持。例如,考虑库或搜索文件夹。

用户的桌面目录是文件系统中的一个位置。桌面文件夹将其与虚拟项目(如所有用户项目、回收站、文档文件夹快捷方式等)合并。

从评论中提取的其他问题和答案

问题
(作者:Lei Yang)为什么以下内容始终为真:

Environment.GetFolderPath(Environment.SpecialFolder.Desktop ) == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)

答案
(作者:David Heffernan):

答案解决了提出的两个具体问题。它不会尝试解决您提出的问题。如果您查看与两个 .net 特殊文件夹值相对应的两个 CSIDL 枚举值,您将看到它们映射到相同的已知文件夹 GUID。这对我来说表明在旧版本的 Windows 中存在差异,但情况已经发生了变化。

请参阅 https://learn.microsoft.com/en-us/windows /win32/shell/csidl

Ctrl+F 代表“FOLDERID_Desktop”

Answer to original question

A directory is a location in the file system. A folder is a location in the shell namespace. A directory is a kind of folder. A virtual folder is not necessarily backed by a directory. For example consider libraries or search folders.

The user's desktop directory is a location in the file system. The desktop folder merges that with virtual items like all users items, recycle bin, shortcut to documents folder etc.

Additional question and answer pulled from comments

Question
(by Lei Yang) Why is the following always true:

Environment.GetFolderPath(Environment.SpecialFolder.Desktop) == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)

Answer
(by David Heffernan):

The answer addresses the two specific questions asked. It doesn't attempt to address the issue you raise. If you look at the two CSIDL enum values that correspond to the two .net special folder values you will see that they map to the same known folder guid. This suggests to me that in older versions of Windows there was a difference but that has changed.

See https://learn.microsoft.com/en-us/windows/win32/shell/csidl

Ctrl+F for "FOLDERID_Desktop"

2024-11-07 17:06:59

真正的答案是,这些可能是不同的,尤其是服务器上的宽度配置文件。
用户可能正在从文件共享运行桌面,或者将其放在本地系统上......
如果重定向,操作系统通常不会通知其他软件它已完成此操作。
但如果你真的想到达那里......

The true answer is that those can be different especially width profiles on servers.
The user might be running a desktop as from a fileshare, or have it on a local system...
If redirected the OS normally doesnt inform other software that it has done that.
But if you realy want to get there...

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