c#中怎么用程序查看一个本机共享的文件夹的实际路径

loveyouchina 2006-01-17 12:52:14
从网上邻居可以看到我的一些文件夹被共享了,但我不知道这个文件夹的实际位置,删除共享就不方便,请问程序怎么实现列出本机共享的文件夹的路径等属性
...全文
488 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwqna 2006-01-17
  • 打赏
  • 举报
回复
应该是包括下面这些信息,在msdn中有

uint32 AccessMask;
boolean AllowMaximum;
string Caption;
string Description;
datetime InstallDate;
uint32 MaximumAllowed;
string Name;
string Path;
string Status;
uint32 Type;






Properties
The Win32_Share class defines the following properties.

AccessMask
Data type: uint32
Access type: Read-only

List of access rights to the given file or directory held by the user or group on whose behalf the instance is returned. This property is only supported under Windows NT and Windows 2000. On Windows 98 and on Windows NT/Windows 2000 FAT volumes, the FULL_ACCESS value is returned instead, indicating no security has been set on the object.


Windows 2000, Windows XP: This property is no longer used due to the expense of calling GetEffectiveRightsFromAcl. You should use the Win32_Share.GetAccessMask method instead. The value of the AccessMask property is set to NULL.




AllowMaximum
Data type: boolean
Access type: Read-only

Number of concurrent users for this resource has been limited. If TRUE, the value in the MaximumAllowed property is ignored.


Caption
Data type: string
Access type: Read-only

Short description (one-line string) of the object.


Description
Data type: string
Access type: Read-only

Description of the object.


InstallDate
Data type: datetime
Access type: Read-only

Object was installed. This property does not need a value to indicate that the object is installed.


MaximumAllowed
Data type: uint32
Access type: Read-only

Limit on the maximum number of users allowed to use this resource concurrently. The value is only valid if the AllowMaximum property is set to FALSE


Name
Data type: string
Access type: Read-only
Qualifiers: Key

Alias given to a path set up as a share on a Windows system.

Example: "public"


Path
Data type: string
Access type: Read-only

Local path of the Windows share.

Example: "C:\Program Files"


Status
Data type: string
Access type: Read-only

Current status of the object. Various operational and non-operational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard drive, may be functioning properly but predicting a failure in the near future). Non-operational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is on-line, yet the managed element is neither "OK" nor in one of the other states.

Values are:

"OK"
"Error"
"Degraded"
"Unknown"
"Pred Fail"
"Starting"
"Stopping"
"Service"
"Stressed"
"Nonrecover"
"Nocontact"
"LostComm"



Type
Data type: uint32
Access type: Read-only

Type of resource being shared. Types include disk drives, print queues, interprocess communications (IPC), and general devices.

Value Meaning
0 Disk Drive
1 Print Queue
2 Device
3 IPC
2147483648 Disk Drive Admin
2147483649 Print Queue Admin
2147483650 Device Admin
2147483651 IPC Admin
loveyouchina 2006-01-17
  • 打赏
  • 举报
回复
谢谢两位,方法都不错,分太少了,不好意思了
wwqna(york)哥们,不知从select * from win32_share还可以得到其它什么属性
lidong6 2006-01-17
  • 打赏
  • 举报
回复
注册表中有:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares
wwqna 2006-01-17
  • 打赏
  • 举报
回复
using System;
using System.Management;

namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("select * from win32_share");
foreach (ManagementObject share in searcher.Get())
{
Console.WriteLine(share["Name"].ToString()); //名称
Console.WriteLine(share["Path"].ToString()); //路径
}
}
}
}
微信小程序系统教程[初级阶段],微信小程序0基础学起,讲解微信小程序开发的基础知识。 微信小程序系统教程共有“微信小程序系统教程[初级阶段]”、“微信小程序系统教程[级阶段]——核心技术”、“微信小程序系统教程[阶段]客服消息+微信支付+九宝电商系统”。 “微信小程序系统教程[阶段]全套课程”包含: 1.微信小程序系统教程[阶段]_客服消息 2.微信小程序系统教程[阶段]_微信支付 3.微信小程序系统教程[阶段]_九宝电商系统 学习“微信小程序系统教程[阶段]”要求有微信小程序的基础。建议先学习“微信小程序系统教程[初级阶段]”、“微信小程序系统教程[级阶段]”,后在报名“微信小程序系统教程[阶段]”。 阶段讲解的客服消息,是针对小程序的。后台程序用接近底层的技术,没有使用三方技术。这样降低同学们学习成本。 微信支付,这部分课程很有难度,要求同学们认真听讲,有不会的技术问题可以请教老师。购买课程后请联系老师,提供单号,给你源程序。 九宝电商系统是一套十分适和学习、项目的课程。既可以系统的学习微信小程序相关知识,还可以修改后上线。 “微信小程序系统教程[级阶段]——核心技术”重点讲解微信小程序事件、组件、API 微信小程序系统教程[初级阶段],微信小程序0基础学起,讲解微信小程序开发的基础知识。 购买课程的同学,可赠送就九宝老师编写的《微信小程序开发宝典》。 购课请咨询qq2326321088

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧