Example #1
0
        private DemoResources getDataFromDemo(string pathToFile)
        {
            var result = new DemoResources();

            try
            {
                using (var fs = new FileStream(pathToFile, FileMode.Open, FileAccess.Read))
                    using (var br = new BinaryReader(fs))
                    {
                        ASCII.GetString(br.ReadBytes(16)).TrimEnd('\0');
                        result.ServerName = ASCII.GetString(br.ReadBytes(260)).TrimEnd('\0');
                        result.PlayerName = ASCII.GetString(br.ReadBytes(260)).TrimEnd('\0');
                        result.MapName    = ASCII.GetString(br.ReadBytes(260)).TrimEnd('\0');
                        ASCII.GetString(br.ReadBytes(264)).TrimEnd('\0');
                        result.Ticks = (Abs(ToInt32(br.ReadBytes(4), 0))).ToString(InvariantCulture);
                    }
            }
            catch (Exception)
            {
                result.ServerName = "Not readable";
                result.PlayerName = "Not readable";
                result.MapName    = "Not readable";
                result.Ticks      = "Not readable";
            }
            return(result);
        }
Example #2
0
        private void Import(string path)
        {
            splitter     = path + @"\";
            FilePathsDem = Directory.GetFiles(path, "*.dem", SearchOption.TopDirectoryOnly);
            dataGridView1.Rows.Clear();
            var DataGridResources = new DemoResources();

            for (int i = 0; i < FilePathsDem.Length; i++)
            {
                dataGridView1.ClearSelection();
                string nameofFile = FilePathsDem[i].Split(new string[] { splitter }, StringSplitOptions.None)[1].Split('.')[0];
                DataGridResources = getDataFromDemo(FilePathsDem[i]);
                dataGridView1.Rows.Add(nameofFile, DataGridResources.MapName, DataGridResources.Ticks, DataGridResources.PlayerName, DataGridResources.ServerName, FilePathsDem[i]);
            }
            ButtonRemoveEmpty.Enabled = true;
            ButtonMoveBookmarksToNewFolder.Enabled = true;
            richTextBox1.Text = null;
        }