Ejemplo n.º 1
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            double           maxPrice  = 0;
            StringBuilder    sb        = new StringBuilder();
            BuildingInfoList bInfoList = new BuildingInfoList();

            string[] files = Directory.GetFiles(Base_URL, "*.html", SearchOption.AllDirectories);

            foreach (string uri in files)
            {
                BuildingInfo info = null;
                if (File.Exists(uri) && BuildingInfo.GetBuildingInfo(uri, out info))
                {
                    sb.AppendLine(info.ToString());
                    rTxBx.Text = sb.ToString();
                    bInfoList.List.Add(info);

                    if (info.count > maxPrice)
                    {
                        maxPrice = info.count;
                    }
                }
            }

            rTxBx.AppendText("---MAX---" + maxPrice.ToString());

            JsonSerializer serializer = new JsonSerializer();

            using (StreamWriter sw0 = new StreamWriter(@"C:\dev\baidu\PriceData.txt"))
                using (JsonWriter writer0 = new JsonTextWriter(sw0))
                {
                    serializer.Serialize(writer0, bInfoList);
                }
        }