Esempio n. 1
0
        public void LoadData()
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                byte[]          buf      = new byte[8192];
                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                Stream resStream = response.GetResponseStream();

                string tempString = null;
                int    count      = 0;

                do
                {
                    count = resStream.Read(buf, 0, buf.Length);

                    if (count != 0)
                    {
                        tempString = Util.UTF8.GetString(buf, 0, count);
                        sb.Append(tempString);
                    }
                }while (count > 0);

                LoadDataFromString(sb.ToString());
            }
            catch (WebException)
            {
                m_log.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead.");
                xmlConfig.SetFileName(configFileName);
                xmlConfig.LoadData();
            }
        }