C# 输出文件未保存到服务器上的给定路径

C# 输出文件未保存到服务器上的给定路径,c#,asp.net,text-to-speech,speech-synthesis,C#,Asp.net,Text To Speech,Speech Synthesis,我正在使用“System.Speech dll”/SpeechSynthesizer从输入的文本创建音频文件,并将其保存到项目目录中的“Sound”文件夹中。 它在本地工作正常,但在服务器上上载后,在给定路径上没有保存任何文件。 我的代码如下所示: string hfdMVoice = Hiddenfield10.Value; // This is the inputted text string path = Server.MapPath("~/Sound/") + Hi

我正在使用“System.Speech dll”/SpeechSynthesizer从输入的文本创建音频文件,并将其保存到项目目录中的“Sound”文件夹中。 它在本地工作正常,但在服务器上上载后,在给定路径上没有保存任何文件。 我的代码如下所示:


string hfdMVoice = Hiddenfield10.Value; // This is the inputted text
string path = Server.MapPath("~/Sound/") + HiddenFiledMaleVoice + ".mp3"; //this is the path where i have 
                                                                          // to save my output file.

Thread th = new Thread(() =>
            {
                speech = new SpeechSynthesizer();
                speech.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);
                speech.Volume = 100;
                speech.Rate = 0;
                if (hfdMVoice.EndsWith(".mp3"))
                {
                    hfdMVoice = hfdMVoice.Remove
                                           (hfdMVoice.Length - 4, 4);
                }
                speech.SetOutputToWaveFile(path); // This method saves the file on the given path.
                speech.SpeakAsync(hfdMVoice);
                string txt_ddd = hfdMVoice;
            });

            th.IsBackground = true;
            th.Start();

它在本地工作正常,但在服务器上不工作。

您应该检查是否对输出文件夹具有必要的写入权限。如果它在dev服务器上工作,但在生产服务器上不工作,那么主要是因为没有授予访问权限