In my MVC application, I added Silverlight Audio Recorder. This recorder records audio using System.Windows.Media; namespace as byte[] , which represents a wav file.
Now I need to save this byte[] as a .wav file on the local drive (server).
So far I have tried the following:
byte[] audioData; // Here I contain my data System.IO.File.WriteAllBytes(@"C:\Temp\yourfile.wav", this.audioData); // Doesn't work BinaryWriter Writer = null; string name = @"C:\Temp\yourfile.wav"; try { Writer = new BinaryWriter(File.OpenWrite(name)); Writer.Write(this.audioData); Writer.Flush(); Writer.Close(); } catch { ... }
But nothing works for me ... What have I done wrong?
Ok Let's say I can send my data as a json string to the controller:
WebClient net = new WebClient(); string data = UTF8Encoding.UTF8.GetString(this.audioData, 0, this.audioData.Length); net.UploadStringAsync(new Uri("/Home/SaveFile", UriKind.Relative), data);
How can I get this data in MVC action?
c # file save silverlight audio
Bryuk
source share