1

我收到了这个时髦的错误:

这是一个简单的 C# 程序,它的源代码是:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Threading;
using System.IO;

namespace SpintaxDecoder
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        List<string> sentences = new List<string>();
        public int Count = 0;

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Text = "Generating...";
            button1.Enabled = false;

            Application.DoEvents();

            string data = richTextBox1.Text;

            Random rand = new Random(this.Timestamp());

            for (; ; )
            {
                string spun = this.spintax(rand, data);

                if (sentences.Contains(spun) != true)
                {
                    sentences.Add(spun);
                }
                else
                {
                    this.Count++;
                }

                if (this.Count == 1000)
                {
                    break;
                }

            }

            label2.Text = this.sentences.Count().ToString();

            foreach (string sentence in sentences)
            {
                richTextBox2.Text += sentence + "\n";
            }

            MessageBox.Show("Completed!", "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information);

            button1.Enabled = true;
            button1.Text = "Start Decoding";

            this.sentences.Clear();
            this.Count = 0;
        }

        public int Timestamp()
        {
            long ticks = DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks;
            ticks /= 10000000;
            return Convert.ToInt32(ticks);
        }

        public string spintax(Random rnd, string str)
        {
            string pattern = "{[^{}]*}";
            Match m = Regex.Match(str, pattern);
            while (m.Success)
            {
                string seg = str.Substring(m.Index + 1, m.Length - 2);
                string[] choices = seg.Split('|');
                str = str.Substring(0, m.Index) + choices[rnd.Next(choices.Length)] + str.Substring(m.Index + m.Length);
                m = Regex.Match(str, pattern);
            }

            return str;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            saveFileDialog1.Filter = "Text File|.txt";
            saveFileDialog1.InitialDirectory = "C:\\";
            saveFileDialog1.ShowDialog();

            string file = saveFileDialog1.FileName;

            if (file.Trim() != "")
            {
                StreamWriter writer = new StreamWriter(file);

                string[] lines = richTextBox2.Text.Split('\n');

                foreach(string line in lines)
                {
                    writer.WriteLine(line);
                }

                writer.Close();
                MessageBox.Show("File saved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}

http://pastebin.com/hUjmAvhe

我不知道我是怎么得到这个错误的。它以前运行良好,现在我打开它并收到此错误。

4

1 回答 1

1

嘿,机器磁盘驱动器上大约 8 万亿位中的一个从 0 翻转到 1。可能不是唯一的。这没有产生 CRC 错误是非常不健康的。话又说回来,也许它确实做到了,并且它自动恢复,拯救了它仍然可以读取的任何数据。在 Windows 事件日志中应该有一些关于它的内容。

在推荐的对策列表中,更换它应该是非常重要的。

于 2013-11-12T20:47:25.167 回答