예제 #1
0
        private void ReadDat4File(string filename)
        {
            if (filename.Length < 1 || !File.Exists(filename))
            {
                return;
            }

            StringBuilder builder = new StringBuilder();

            var md = new RageAudioMetadata5();

            using (RageDataFileReadReference file = new RageDataFileReadReference(filename))
            {
                md.Read(file);
            }

            //   using (RageDataFileWriteReference file = new RageDataFileWriteReference(Path.ChangeExtension(filename, ".output.rel54")))
            //    {
            //       md.Write(file);
            //   }

            // File.WriteAllText(Path.ChangeExtension(filename, ".txt"), md.ToString());

            var xml = new ResourceXmlWriter5(Path.ChangeExtension(filename, ".xml"));

            xml.WriteData(md);

            /*
             * using (StreamWriter writer = new StreamWriter(Path.ChangeExtension(filename, ".txt")))
             * {
             *  writer.Write(md.ToString());
             * }*/
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (_currentFile != null)
            {
                var extension = Path.GetExtension(_filename);

                string filter = string.Format("RAGE Audio File (*{0})|*{0}|XML File (*.xml)|*.xml|Text file (*.txt)|*.txt|All files (*.*)|*.*", extension);

                using (var sfd = new SaveFileDialog {
                    Filter = filter
                })
                {
                    sfd.FileName = Path.GetFileName(_filename);

                    var result = sfd.ShowDialog();

                    switch (result)
                    {
                    case DialogResult.Cancel: return;

                    case DialogResult.OK:
                        Enabled = false;
                        string ext = Path.GetExtension(sfd.FileName);

                        if (ext == ".xml")
                        {
                            if (_currentFile is RageAudioMetadata4)
                            {
                                MessageBox.Show("Error: Exporting of this format to xml is not yet supported.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                return;

                                //var xml = new ResourceXMLWriter5(Path.ChangeExtension(filename, ".xml"));

                                // xml.WriteData(currentFile as RageAudioMetadata5);
                            }

                            var xml = new ResourceXmlWriter5(Path.ChangeExtension(sfd.FileName, ".xml"));

                            xml.WriteData(_currentFile as RageAudioMetadata5);
                        }

                        else if (ext == ".txt")
                        {
                            File.WriteAllText(Path.ChangeExtension(sfd.FileName, ".txt"), _currentFile.ToString());
                        }

                        else
                        {
                            using (RageDataFileWriteReference file = new RageDataFileWriteReference(sfd.FileName))
                            {
                                _currentFile.Write(file);
                            }
                        }

                        Enabled = true;
                        MessageBox.Show(string.Format("Successfully exported to {0}.", sfd.FileName));

                        break;
                    }

                    sfd.Dispose();
                }
            }
        }