Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 252.8k

How to get files from https server using C# .NET?

Jun 30 2020 2:55 AM
Hello,
 
How to Get Files from Http Server using c# .net?
 
I want to get files from web server using c# .net.
 
f.XMarksSheetName etc. my file name and files already stored in suppose my path is  "https://abc.com/images/Upload/" path.
Its getting error:- The remote server returned an error: (404) Not Found.
 
Please help me.
 
I have tried:-
  1. public void ExportImages(List fd)  
  2. {  
  3. foreach (var f in fd)  
  4. {  
  5. HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("https://abc.com/images/Upload/" + f.XMarksSheetName + "," + f.XCertificateName + "," + f.XIIMarksSheetName + "," + "," + f.XIICertificateName + "," + f.GMarksSheetName + "," + f.GCertificateName + "," + f.FileName + "," + f.FileNameNationalId + "," + f.FileNamePassport);  
  6. httpRequest.Method = WebRequestMethods.Http.Get;  
  7. HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();  
  8. //Stream httpResponseStream = httpResponse.GetResponseStream();  
  9. StreamReader sr = new StreamReader(httpResponse.GetResponseStream());  
  10. var results = sr.ReadToEnd();  
  11. sr.Close();  
  12. }  
  13. }  
Thanks in Advance.
Ankit Agarwal
Software Engineer

Answers (1)