Exemplo n.º 1
0
        private void getDistributionAndVersion()
        {
            string sContent = CUtility.GetContentFromFile("/etc/issue", true);
            string vinfo    = String.Empty;

            distribution        = DistriType.Unknown;
            distributionVersion = DistriVersion.Unknown;

            //(K)Ubuntu, Suse
            if (sContent.IndexOf("kubuntu", StringComparison.CurrentCulture) > -1)
            {
                distribution = DistriType.Kubuntu;
            }
            if (sContent.IndexOf("ubuntu", StringComparison.CurrentCulture) > -1)
            {
                distribution = DistriType.Ubuntu;
            }
            if (sContent.Contains("suse"))
            {
                distribution = DistriType.Suse;
            }
            if (sContent.Contains("pclinuxos"))
            {
                distribution = DistriType.PcLinuxOs;
            }
            if (sContent.Contains("arch"))
            {
                distribution = DistriType.ArchLinux;
            }

            //Version
            if (distribution == DistriType.Ubuntu)
            {
                try {
                    sContent = CUtility.GetContentFromFile("/etc/lsb-release", true);
                    if (sContent.IndexOf("hardy", StringComparison.CurrentCulture) > -1)
                    {
                        distributionVersion = DistriVersion.Hardy;
                    }
                    if (sContent.IndexOf("intrepid", StringComparison.CurrentCulture) > -1)
                    {
                        distributionVersion = DistriVersion.Intrepid;
                    }
                    if (sContent.Contains("jaunty"))
                    {
                        distributionVersion = DistriVersion.Jaunty;
                    }
                    if (sContent.Contains("karmic"))
                    {
                        distributionVersion = DistriVersion.Karmic;
                    }
                    vinfo = ", version: " + distributionVersion;
                } catch (Exception e) {
                    Console.WriteLine("Couldn't detect the version of your distribution, error: " + e.Message);
                }
            }
            Console.WriteLine("It seems you're using an flavour of " + distribution + vinfo);
        }
        private void getDistributionAndVersion()
        {
            string sContent = CUtility.GetContentFromFile("/etc/issue",true);
            string vinfo=String.Empty;
            distribution = DistriType.Unknown;
            distributionVersion = DistriVersion.Unknown;

            //(K)Ubuntu, Suse
            if (sContent.IndexOf("kubuntu",StringComparison.CurrentCulture)>-1)
                distribution=DistriType.Kubuntu;
            if (sContent.IndexOf("ubuntu",StringComparison.CurrentCulture)>-1)
                distribution=DistriType.Ubuntu;
            if (sContent.Contains("suse"))
                distribution=DistriType.Suse;
            if (sContent.Contains("pclinuxos"))
                distribution=DistriType.PcLinuxOs;
            if (sContent.Contains("arch"))
                distribution=DistriType.ArchLinux;

            //Version
            if (distribution == DistriType.Ubuntu) {
                try {
                    sContent = CUtility.GetContentFromFile("/etc/lsb-release",true);
                    if (sContent.IndexOf("hardy",StringComparison.CurrentCulture)>-1)
                        distributionVersion=DistriVersion.Hardy;
                    if (sContent.IndexOf("intrepid",StringComparison.CurrentCulture)>-1)
                        distributionVersion=DistriVersion.Intrepid;
                    if (sContent.Contains("jaunty"))
                        distributionVersion = DistriVersion.Jaunty;
                    if (sContent.Contains("karmic"))
                        distributionVersion = DistriVersion.Karmic;
                    vinfo = ", version: " + distributionVersion;
                } catch (Exception e) {
                    Console.WriteLine("Couldn't detect the version of your distribution, error: " + e.Message );
                }
            }
            Console.WriteLine("It seems you're using an flavour of "+distribution+vinfo);
        }