是么?我也想知道,共享一下如何?谢谢啦

解决方案 »

  1.   

    static void SetDefaultWeb(string DefaultPath)
    {
    string _server = "localhost";
    string _website = "1"; string strPath = "IIS://" + _server + "/W3SVC/" + _website +"/ROOT";
    try
    {
    System.DirectoryServices.DirectoryEntry rootfolder = new DirectoryEntry(strPath);
    rootfolder.Properties["Path"].Value=Path.GetFullPath(DefaultPath);
    rootfolder.Properties["DefaultDoc"][0]="Default.aspx";
    rootfolder.Properties["AccessRead"][0] =true;
    rootfolder.Properties["AccessExecute"][0] = false;
    rootfolder.Properties["AccessWrite"][0] = false;
    rootfolder.Properties["AppIsolated"][0]=1;
    rootfolder.Properties["EnableDirBrowsing"][0] = false;
    rootfolder.Properties["AccessScript"][0] = true;
    rootfolder.Properties["ContentIndexed"][0] = false;
    rootfolder.Properties["DontLog"][0]=true;
    rootfolder.Properties["AccessSource"][0]=false;
    rootfolder.CommitChanges();

    catch(Exception e)
    {
    throw new Exception("Can't connect to the server ["+ _server +"] ...",e);
    }
    }