如何在Windows OS中获取桌面文件夹,文件,快捷方式详细信息 [英] How to get Desktop folders,files,Shortcuts details in windows os
问题描述
Hai ALL,
我想获取每个Windows Machines用户桌面详细信息,例如文件夹,文件,快捷方式名称,大小,createdDate,修改日期,文件类型(.txt,.xls).每台机器都有许多用户,桌面文件,文件夹,快捷方式都不同.
如何使用C#获取这些信息.
样本:
系统名称:abc
用户:
user1
user2
管理员
用户详细信息:
sample.txt-文件,createdDate,大小
样本-文件夹,createdDate,大小
sample1-快捷方式,createdDate,大小
user2详细信息:
sample2.txt-文件,createdDate,大小
sample2-文件夹,createdDate,大小
sample2- Shortcut,createdDate,size
Hai ALL,
I would like to get each windows Machines user desktop details like folder,file,shortcut names,size,createdDate,Modified Date,file Type(.txt,.xls). Each machine has many users, the desktop files,folders,shortcuts are different.
How to get these information using C#.
Sample:
system Name : abc
users:
user1
user2
Administrator
user Details:
sample.txt - File,createdDate,size
sample - Folder,createdDate,size
sample1- Shortcut,createdDate,size
user2 Details:
sample2.txt - File,createdDate,size
sample2 - Folder,createdDate,size
sample2- Shortcut,createdDate,size
推荐答案
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
...将返回一个文件夹路径,然后您可以使用System.IO中的常规文件处理方法进行进一步的处理.
要获得所有用户的桌面,您需要假定它们都位于文件夹树的同一区域,然后从该方法返回的位置退回到一个级别并枚举目录.
您可能需要管理权限才能查看其他人的桌面文件夹.
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
... will return a folder path which you can then use the normal file handling methods in System.IO to do further processing with.
To get the desktops for all users, you need to assume that they are all in the same area of the folder tree, and step back a level from what that method returns and enumerate directories.
You may well need administrative rights to look into other people''s desktop folders.
您可以将计算机的所有用户转换为文本文件或在控制台上
以下代码将在文本文件中为您的计算机提供所有用户
净用户> C:\ user.txt
在cmd上键入此命令,它将为您提供c驱动器中文本文件的用户
you can get all user of computer to text file or on console
following code will gives you all users of your machine in text file
net user > C:\user.txt
type this command on cmd and it will gives you users in text file in c drive
这篇关于如何在Windows OS中获取桌面文件夹,文件,快捷方式详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!