Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Taking file from one server to another server using c sharp

$
0
0

Hi All,

I have two servers with static IP, out of those two one is client server.

I want to bring some files(.bak file) from client server to our server in my console application.

private void Downloadfile(string filename, string userName, string password, string domainName)
        {

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(""http://server ip/C:/Support/Backups"" +filename);
                request.Credentials = new NetworkCredential(userName, password, domainName);

                request.AllowAutoRedirect = true;

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                using (FileStream stream = new FileStream(Path.Combine(currentDirectory, dbname), FileMode.Create))
                {
                    response.GetResponseStream().CopyTo(stream);
                }

                response.Close();

}

i am doing something like above but getting error at this line

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Please help.

Thanks in advance.


blrSvsTech


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>