2009-10-14 50 views
1

我可以在下面顯示的代碼中使用Microsoft.Web.Administration dll很容易地在IIS7中創建一個虛擬目錄,但我一直在拉我的頭髮試圖找出如何在虛擬目錄創建後給「網絡服務」寫入權限。任何人都可以將我指向正確的方向嗎?Microsoft.Web.Administration VirtualDirectory權限

Private Sub CreateVirDir(ByVal WebSite As String, ByVal AppPath As String, ByVal VirPath As String, ByVal DirPath As String) 
    Dim sm As New Microsoft.Web.Administration.ServerManager() 
    Dim cpapp As Microsoft.Web.Administration.Application = sm.Sites(WebSite).Applications(AppPath) 
    cpapp.VirtualDirectories.Add(VirPath, DirPath) 
    sm.CommitChanges() 
End Sub 

回答

1

假設這是NTFS寫入權限,則不會對虛擬目錄本身應用寫入權限。您需要在虛擬目錄指向的文件夾上應用此權限。

您可以使用下面的命名空間以編程方式設置NTFS權限:

System.IO 
System.Security.AccessControl 

以下鏈接都有演示瞭如何操作的示例代碼NTFS ACL的:

FileSecurity Class (MSDN Library)