C#如何判断一个文件夹已经共享!

2025-03-02 11:40:06
推荐回答(2个)
回答1:

这是我做的,你看看。应该能实现你的效果

解决方法:在C#中如何实现使文件夹成为共享或Web共享

Web共享
==============
DirectoryEntry ent = new DirectoryEntry("IIS://oh35d-install1/w3svc");
DirectoryEntry entchild = new DirectoryEntry();
entchild = ent.Children.Add("5","IIsWebServer");
entchild.CommitChanges();
entchild.Properties["ServerBindings"].Value = ":123:";
entchild.Properties["ServerState"].Value = 2;
entchild.Properties["ServerComment"].Value = "TESTSITE";
entchild.CommitChanges();
DirectoryEntry vdir = entchild.Children.Add("ROOT","IIsWebVirtualDir");
vdir.CommitChanges();
vdir.Properties["AppIsolated"].Value = 2;
vdir.Properties["Path"].Value = @"C:\Inetpub\wwwroot";
vdir.Properties["AuthFlags"].Value = 5;
vdir.Properties["DirBrowseFlags"].Value = 1073741886;
vdir.Properties["AccessFlags"].Value = 513;
vdir.CommitChanges();
entchild.CommitChanges();
ent.CommitChanges();

回答2:

在别人的机器上,还是自己的机器上?我试过判断别人的机器上文件有没有共享,直接判断\\IP地址\文件夹是否存在就可以