2011-12-08 10 views
0

現在Unknown error (0x80005000)を取得 - リンクされたC#で "COM例外" 次のコードに string virtualDirectory = GetVirtualDirPath("IIS://localhost", "1", reportUrl);DirectoryEntry.Properties ["Path"]。Value.ToString(); IIS7の問題。 C#

static string GetVirtualDirPath(string iisHost, 
           string siteName, string vdName) 
    { 
     string adsiPath = iisHost + "/W3SVC/" + siteName + "/Root/test/" + vdName; 

     try 
     { 
      DirectoryEntry entry = new DirectoryEntry(adsiPath); 
      return entry.Properties["Path"].Value.ToString(); 
     } 
     catch (Exception ex) 
     { 
      // If Virtual Directory is not found, 
      // it will throw exception. 
      return ""; 
     } 

     return ""; 
    } 

私は "/テスト" 内の仮想ディレクトリとして "共有" のセットアップを持っています(httpを実行する:// localhostを/ test/share)、そのフォルダに関連する権限を与えようとしました。

これはIIS6とIIS7では動作しないことを読んだことがありますか?もしそうなら、同等のコードは何ですか?

+0

は、この記事http://support.microsoft.com/kb/2428673を見て、あなたに –

答えて

2

IIS7は管理された管理APIを公開するようになりました。その情報はfound hereです。

具体的には、仮想ディレクトリの管理を容易にするクラスがあります。

var iis = new ServerManager(); 
var site = iis.Sites["SiteName"]; 
var application = site.Applications["ApplicationName"]; 
var directories = application.VirtualDirectories; 
//proceed to determine the physical path of appropriate directory 
var path = directories[0].Path; 
+0

@mrDisappointmentを助けるかもしれない - 名前空間は、ServerManagerのは、下に座っていた、有望に見えますか?私はこのアプローチを試してみよう! – JustAnotherDeveloper

関連する問題