Asp.net的Silverlight [英] Silverlight with Asp.net

查看:71
本文介绍了Asp.net的Silverlight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我正在使用Silverlight以.wav格式录制音频并进行存储.

当我使用SaveFileDialog Box时,它将保存文件.

这是以下代码.

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);



但是当我想在没有savefiledialog的情况下执行此操作时,它给我一个错误
不允许文件操作.访问被拒绝.



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);



我检查BinaryWriter是否带有Stream参数.但是我没有找到一种方法来将我的自定义路径传递给Stream,以便BinaryWriter在我指定的位置写入wave文件.


谢谢.



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.

推荐答案

Silverlight无法直接访问用户计算机,例如您的示例"E"驱动器.如果要存储在计算机上,请查看Silverlight范式中的称为隔离存储"的内容.

Silverlight代码可以访问它的少量空间.
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.


正常模式"下的Silverlight无法访问本地文件系统.
使用提升的特权的Si​​lverlight 5可以完全访问文件系统(但是仍然缺少某些.NET部件,例如DriveInfo).

因此,如果您真的希望拥有这种直接访问权限,则需要启用提升的信任(这需要代码签名),并且需要在浏览器中进行复杂的设置(与"Out of Browser"(相对于"Out of Browser")不同)限制较少).
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).


这篇关于Asp.net的Silverlight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆