Beispiel #1
0
        /// <summary>Retrieves all environment variable names and their values from the current process.</summary>
        /// <returns>An <see cref="T:System.Collections.IDictionary" /> that contains all environment variable names and their values; otherwise, an empty dictionary if no environment variables are found.</returns>
        /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission to perform this operation.</exception>
        /// <exception cref="T:System.OutOfMemoryException">The buffer is out of memory.</exception>
        /// <filterpriority>1</filterpriority>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        /// </PermissionSet>
        public static IDictionary GetEnvironmentVariables()
        {
            Hashtable hashtable = new Hashtable();

            foreach (string text in Environment.GetEnvironmentVariableNames())
            {
                hashtable[text] = Environment.internalGetEnvironmentVariable(text);
            }
            return(hashtable);
        }
Beispiel #2
0
        private static Hashtable GetEnvironmentVariablesNoCase()
        {
            Hashtable hashtable = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);

            foreach (string text in Environment.GetEnvironmentVariableNames())
            {
                hashtable[text] = Environment.internalGetEnvironmentVariable(text);
            }
            return(hashtable);
        }