开发者

Get .svc file info of IIS web service on remote computer

开发者 https://www.devze.com 2023-03-15 10:34 出处:网络
i\'ve written a code to retrieve list of IIS services on a remote computer, now I am trying to retrieve information about the .svc file of the web service. The code below works for all the services th

i've written a code to retrieve list of IIS services on a remote computer, now I am trying to retrieve information about the .svc file of the web service. The code below works for all the services that are stored in the inetpub folder, but i know it is not necessary to store the services there and it can be saved anywhere.

public static void IISWebSvcLister(string Hos)
    {
        try
        {
            string s = null;
            Hos = Hos.Trim();
            DirectoryEntry w3svc = new DirectoryEntry("IIS://" + Hos + "/w3svc/1/root");

            foreach (DirectoryEntry de in w3svc.Children)
            {
                if (de.Children.ToString() != null)
                {
                    s += de.Name.ToString() + "\n";
                    //string sp = HttpContext.Current.Server.MapPath(@"~\\"+Hos+"\c$\inetpub\wwwroot\");

                    try
 开发者_如何学运维                   {
                        string[] filePaths = Directory.GetFiles(@"\\" + Hos + @"\c$\inetpub\wwwroot\" + de.Name.ToString(), "*.svc", SearchOption.AllDirectories);

                        for (int i = 0; i < filePaths.Length; i++)
                        {
                            FileInfo fi = new FileInfo(filePaths[i]);
                            Console.Write(fi.CreationTime.ToString() + "\t" + fi.Length.ToString());
                            string[] k = filePaths[i].Split('\\');
                            filePaths[i] = k[k.Length-2]+"\\"+k[k.Length - 1];
                            Console.WriteLine("\t" + filePaths[i]);
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine(de.Name.ToString());
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }

How do i get the files for the services not stored in c:\inetpub\wwwroot ?

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消