How to rewrite text in a console application?

public class WaveFormat { byte[] ByteSrcMas; BitArray BitSrcMas,BitDstMas; public int BpS; public int Size; public int Count; int Pas; public int Pass; public WaveFormat() { } public int ParseWaveFile(string file) { ByteSrcMas = File.ReadAllBytes(file); //считывание всего файла if ((ByteSrcMas[0] != 'R') || (ByteSrcMas[1] != 'I') || (ByteSrcMas[2] != 'F') || (ByteSrcMas[3] != 'F')) //проверка заголовка RIFF return 1; if ((ByteSrcMas[8] != 'W') || (ByteSrcMas[9] != 'A') || (ByteSrcMas[10] != 'V') || (ByteSrcMas[11] != 'E')) //проверка заголовка WAVE return 1; if ((ByteSrcMas[12] != 'f') || (ByteSrcMas[13] != 'm') || (ByteSrcMas[14] != 't') || (ByteSrcMas[15] != ' ')) //проверка заголовка fmt return 1; byte[] mas = new byte[4]; //считывание размера заголовков mas[0] = ByteSrcMas[16]; mas[1] = ByteSrcMas[17]; mas[2] = ByteSrcMas[18]; mas[3] = ByteSrcMas[19]; int value = BitConverter.ToInt32(mas, 0); byte[] mas2 = new byte[2]; mas2[0] = ByteSrcMas[20]; mas2[1] = ByteSrcMas[21]; int tag = BitConverter.ToInt16(mas2, 0); if (tag != 1) return 2; Count = 20 + 14; mas2[0] = ByteSrcMas[Count]; mas2[1] = ByteSrcMas[Count + 1]; BpS = BitConverter.ToInt16(mas2, 0); Count = Count + value - 16 + 2; if ((ByteSrcMas[Count] == 'f') && (ByteSrcMas[Count + 1] == 'a') && (ByteSrcMas[Count + 2] == 'c') && (ByteSrcMas[Count + 3] == 't')) { Count = Count + 3 + 1; //пропуск области fact mas[0] = ByteSrcMas[Count]; mas[1] = ByteSrcMas[Count + 1]; mas[2] = ByteSrcMas[Count + 2]; mas[3] = ByteSrcMas[Count + 3]; value = BitConverter.ToInt32(mas, 0); Count = Count + 3 + value + 1; } if ((ByteSrcMas[Count] != 'd') || (ByteSrcMas[Count + 1] != 'a') || (ByteSrcMas[Count + 2] != 't') || (ByteSrcMas[Count + 3] != 'a')) return 1; Count = Count + 3 + 1; mas[0] = ByteSrcMas[Count]; mas[1] = ByteSrcMas[Count + 1]; mas[2] = ByteSrcMas[Count + 2]; mas[3] = ByteSrcMas[Count + 3]; Size = BitConverter.ToInt32(mas, 0); //размер аудиоданных Count = Count + 3; BitSrcMas = new BitArray(ByteSrcMas); Pass = (Count * 8)+8; return 0; } } 
  • The question is incomprehensible. - Specter
  • It is not written in the console application. How to rewrite this program in console mode. - Arenew777

2 answers 2

The WaveFormat class WaveFormat not tied to any technology, take it and use it at least in the oblique, at least in the web application.

  • ok) he gives me errors)) - Arenew777
  • 1) "ConsoleApplication1.WaveFormat.ByteArray" is a "field", but used as a "type" - Arenew777
  • Help. Throw off the converted text. Nothing happens. The head has already broken, how to convert. He already used the WaveFormat class. Does not work. Maybe I made a mistake. But I do not see him. When you run some errors. - Arenew777
  • Show completely application in a console type. - Freezze
  • send mail throw there. No opportunity to post here - Arenew777

As already mentioned, this class is not tied to technology and can be easily migrated to a console application - just copy it to another project. In your case, you just use it incorrectly, namely:

 ConsoleApplication1.WaveFormat.ByteArray 

Where does such an appeal to the class come from? It has no static methods and properties. To use, you need to create an object and call the necessary methods on it:

 var wave = new WaveFormat(); wave.НужныйМетод(); 
  • I thank him, and so he downloaded the Wav files. I need this piece of program interrupted in console mode! and it is in the BitSrcMas = new BitArray (ByteSrcMas); swears on BitArray and writes that there is an error "ConsoleApplication1.WaveFormat.ByteArray" is a "field", but used as a "type". Somebody kill this piece of the program in console mode !!!! to work !!! I already broke my head over this and my knowledge of Visual C # has dried up. - Arenew777
  • I do not understand you - what does it mean to “kill in console mode”? This miracle program works for me in the console and does not give errors, what do you want from it? - wind
  • I use the following code: var f = new WaveFormat (); f.ParseWaveFile (@ "C: \ booze.wav"); Console.WriteLine (f.Count); As a result, the count is displayed ... How to reproduce your problem? - wind