以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助SaveFileDialog怎么保存数据。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=17119)

--  作者:view360
--  发布时间:2012/3/4 14:30:00
--  求助SaveFileDialog怎么保存数据。

Dim yy As WinForm.ListBox = e.Form.Controls("ListBox1")
Dim sp As New DotNetSpeech.SpVoice()
Dim vl As String = e.Form.Controls("txtContent").Value \'获得要朗读的文本
sp.Rate = e.Form.Controls("boxSpeed").Value \'设置语速
sp.Voice = sp.GetVoices(String.Empty,String.Empty).Item(yy.SelectedIndex) \'选择语音库
Dim Stream As new DotNetSpeech.SpFileStreamClass()
Stream.Open("C:\\Documents and Settings\\All Users\\桌面\\d.wav", DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite, False)
sp.AudioOutputStream = Stream
sp.Speak(vl,DotNetSpeech.SpeechVoiceSpeakFlags.SVSFDefault)
Stream.Close()

 

上面的代码直接在桌面上生成一个d.wav的文件,但是,我现在想要用保存对话框,自定义存储位置,及文件名。查到了这个SaveFileDialog 但是不晓得如何才能把上面的录音保存下来,求助各老师!谢谢了

 

下面是我查到的savefiledialog用法,但是还是不明白如何调用。

 

Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog
dlg.Filter= "wav|*.wav" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    MessageBox.Show("你要保存为:" & dlg.FileName,"提示") \'提示用户选择的文件
End If

[此贴子已经被作者于2012-3-4 14:30:49编辑过]

--  作者:czy
--  发布时间:2012/3/4 15:42:00
--  

将原来的路径改成dlg.FileName就可以了吧。

 

Dim yy As WinForm.ListBox = e.Form.Controls("ListBox1")
Dim sp As New DotNetSpeech.SpVoice()
Dim vl As String = e.Form.Controls("txtContent").Value \'获得要朗读的文本
sp.Rate = e.Form.Controls("boxSpeed").Value \'设置语速
sp.Voice = sp.GetVoices(String.Empty,String.Empty).Item(yy.SelectedIndex) \'选择语音库
Dim Stream As new DotNetSpeech.SpFileStreamClass()
Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog
dlg.Filter= "wav|*.wav" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    Stream.Open(dlg.FileName, DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite, False)
End If
sp.AudioOutputStream = Stream
sp.Speak(vl,DotNetSpeech.SpeechVoiceSpeakFlags.SVSFDefault)
Stream.Close()


--  作者:view360
--  发布时间:2012/3/4 16:03:00
--  
感谢CZY老大。。代码看明白了,继续学习中!非常感谢。
[此贴子已经被作者于2012-3-4 16:04:21编辑过]