Esempio n. 1
0
        private void SaveFile(string path)
        {
            for (int i = 0; i < x9aFile.Voices.Length; i++)
            {
                x9aFile.Voices[i] = Voices[i].Voice;
            }

            try
            {
                x9aFile.Save(path);
            }
            catch
            {
                MessageBox.Show("The file could not be saved.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            LoadedFilePath = path;
        }
Esempio n. 2
0
        private X9aFile ParseX9A(string path)
        {
            X9aFile x9aFile;

            byte[] data = File.ReadAllBytes(path);
            using (MemoryStream memoryStream = new MemoryStream(data, false))
                x9aFile = X9aFile.Parse(path);

            // as a sanity check, we re-encode the parsed file and check that we end up with exactly the same bytes
            // this should give us confidence that the file is in a supported format
            byte[] data2;
            using (MemoryStream memoryStream = new MemoryStream(data.Length))
            {
                x9aFile.Save(memoryStream);
                data2 = memoryStream.ToArray();
            }

            if (!data2.SequenceEqual(data))
            {
                throw new InvalidDataException("Re-encoded X9A is different from input");
            }

            return(x9aFile);
        }