download the file from the navigation link from the website by logging in from Console application C#
<p>I would like to download excel file from the website using user name and password. After logging in, there is a link for downloading the excel file. When I clicked it, the Save as message asks me to save in the desired folder. I am using this function and it doesn't work. It just downloads the html page. Any suggestions would be appreciated. </p>

<p>ftpfullpath is the url + file name</p>

<p>if I use the login form url, it shows error.</p>

<pre><code>    public static void DownloadFileFTP()
        {
            //Delete if Data feed file is already existed
            if (File.Exists(GetFileName.source_path))
            {
                File.Delete(GetFileName.source_path);
            }

            //Create a WebClient
            WebClient request = new WebClient();

            //Set up credentials
            request.Credentials = new NetworkCredential(Properties.Resources.UserName, Properties.Resources.Password);

            //Download the data into Byte array
            byte[] fileData = request.DownloadData(Properties.Resources.ftpfullpath);

            //Create a Filestream to write to Byte array
            FileStream sourceFile = File.Create(GetFileName.source_path);

            try
            {
                //Write full byte array to the file
                sourceFile.Write(fileData, 0, fileData.Length);
                Console.WriteLine("Download Complete " + GetFileName.source_path);
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            finally
            {
                if (sourceFile != null)
                {
                sourceFile.Close();
                sourceFile = null;
                }

            }
        }
</code></pre>
