getProperty() public static method

Return the system property for this name, or null if no matching property value can be found.
public static getProperty ( string name ) : string
name string
return string
Example #1
0
        private static string sysPropToDir(string propKey, string envKey, string def)
        {
            // lookup system property
            string val = SysProps.getProperty(propKey);

            // fallback to environment variable
            if (val == null)
            {
                val = Environment.GetEnvironmentVariable(envKey);
            }

            // fallback to def if provides
            if (val == null && def != null)
            {
                val = def;
            }

            // if still not found then we're toast
            if (val == null)
            {
                throw new Exception("Missing " + propKey + " system property or " + envKey + " env var");
            }

            // check if relative to home directory (fand, fant)
            bool checkExists = true;

            if (val.StartsWith("$home"))
            {
                val         = FileUtil.combine(m_homeDir, val.Substring(6));
                checkExists = false;
            }

            // check that it is a valid directory
            if (checkExists && !Directory.Exists(val))
            {
                throw new Exception("Invalid " + propKey + " dir: " + val);
            }

            // make sure path gets normalized
            return(new DirectoryInfo(val).FullName);
        }