C# Download SRTM HGT Files
Posted: Thu Jun 03, 2021 11:16 am America/New_York
Hi there,
I have a simple issue when i try to download HGT file from earthdata via unity+ C#
I'm Getting this Error :
WebException: The remote server returned an error: (401) Unauthorized.
Any Help would be grateful.
My Script :
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using UnityEngine;
public class DownloadSRTM : MonoBehaviour
{
public string FileUrl = "https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/2000.02.11/N38E001.SRTMGL1.hgt.zip";
public string User = "username";
public string Pass = "userpassword";
public string DownloadPath = @"D:\SRTM\srtm.zip";
// Start is called before the first frame update
async void Start()
{
await SRTMDownload();
}
// Update is called once per frame
void Update()
{
}
private async Task SRTMDownload()
{
var client = new WebClient();
client.Credentials = new NetworkCredential(User, Pass, "https://e4ftl01.cr.usgs.gov");
client.UseDefaultCredentials = true;
await client.DownloadFileTaskAsync(new Uri(FileUrl),DownloadPath);
}
}
I have a simple issue when i try to download HGT file from earthdata via unity+ C#
I'm Getting this Error :
WebException: The remote server returned an error: (401) Unauthorized.
Any Help would be grateful.
My Script :
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using UnityEngine;
public class DownloadSRTM : MonoBehaviour
{
public string FileUrl = "https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/2000.02.11/N38E001.SRTMGL1.hgt.zip";
public string User = "username";
public string Pass = "userpassword";
public string DownloadPath = @"D:\SRTM\srtm.zip";
// Start is called before the first frame update
async void Start()
{
await SRTMDownload();
}
// Update is called once per frame
void Update()
{
}
private async Task SRTMDownload()
{
var client = new WebClient();
client.Credentials = new NetworkCredential(User, Pass, "https://e4ftl01.cr.usgs.gov");
client.UseDefaultCredentials = true;
await client.DownloadFileTaskAsync(new Uri(FileUrl),DownloadPath);
}
}