Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET audio-video , +
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 5-Jan-12 21:31pm
Edited 19-Mar-12 1:55am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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).
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 280
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 120
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 19 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100