Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello Friends,

I'm using Silverlight to record an audio in .wav format and to store.

When I'm using SaveFileDialog Box then it save the file.

Here is the following code.
Stream stream = saveFileDialog.OpenFile();
            WavManager.SavePcmToWav(_sink.BackingStream,stream,_sink.CurrentFormat);
            stream.Close();

 public static void SavePcmToWav(Stream rawData,Stream output, AudioFormat audioFormat)
        {
            if (audioFormat.WaveFormat != WaveFormatType.Pcm)
                throw new ArgumentException("Only PCM coding is supported.");
            BinaryWriter bwOutput = new BinaryWriter(output);


But When I want to do this without savefiledialog then it gives me an error
File Operation is not Permitted. Access Denied.
//Stream stream = saveFileDialog.OpenFile();
FileStream stream = new FileStream(@"E:/Audio/abc.wav",FileMode.Create);
            WavManager.SavePcmToWav(_sink.BackingStream,stream,_sink.CurrentFormat);
            stream.Close();

 //public static void SavePcmToWav(Stream rawData,Stream output, AudioFormat 
//audioFormat)
public static void SavePcmToWav(Stream rawData,FileStream output, AudioFormat 
audioFormat)
        {
            if (audioFormat.WaveFormat != WaveFormatType.Pcm)
                throw new ArgumentException("Only PCM coding is supported.");
            BinaryWriter bwOutput = new BinaryWriter(output);


I Checked BinaryWriter takes an Stream argument. But I didn't find a way how to pass my custom path to Stream so that BinaryWriter write the wave file at my specified location.


Thanks.
Posted
Updated 19-Mar-12 0:55am
v2

Silverlight has no direct access to the users machine like your example to the "E" drive. If you want to store on the machine look at something called isolated storage within the silverlight paradigm.

Its a small amount of space accessible by silverlight code.
 
Share this answer
 
Silverlight in 'normal mode' has no access to the local filesystem.
Silverlight 5 using elevated priviledges has full access to the file system (but some .NET parts are still missing, like DriveInfo).

So if you really want to have this kind of direct access, you'll need to enable elevated trust, which requires code signing, and a complex setup if you want it in browser (as opposed to 'Out of Browser' which is less restrictive).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900