Q:

C# Setup Issue.

    private void ReadText(string text)
    {
        string add = "http://translate.google.com/translate_tts?tl=ta&q=";
        add += HttpUtility.UrlEncode(text, Encoding.GetEncoding("utf-8"));
        try
        {
            using (var client = new WebClient())
            {
                try
                {
                    client.Headers[HttpRequestHeader.UserAgent] =
                        "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1";                                            }
                catch
                {
                    MessageBox.Show("Intenet error");
                }

                try
                {                        
                    client.DownloadFile(add, "mp3CriationTest.mp3");
                }
                catch 
                {
                    MessageBox.Show("NAudio Error");
                }
            }
        }
        catch (WebException e3)
        {
            MessageBox.Show("ReadText error: " + e3);

        }
    }

I am using nAudio to do google text-to-speech(tts). This code working much better for me when I run on visual studio debug(F5). But When I created setup file I ll get the exception message "NAudio Error". So its obvious there is a problem on saving/creating "mp3CriationTest.mp3" on Application folder of my setup. But Creating "mp3CriationTest.mp3" on debug folder is works fine when I use Visual Studio debug(F5).
Can anyone know what was the issue? Plaese help.

A:

You cannot write directly into the program files folder unless you have administrative privileges. You can save the file to the application data folder (environment specified); like 
string fileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + "mp3test.mp3";
client.DownloadFile(add, fileName);

