要访问子文件夹首先端口要设置正确,然后设置如下:
在Unity中使用UnityWebRequest测试,测试代码如下:
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
public class FileDownloader : MonoBehaviour
{
void Start()
{
StartCoroutine(DownloadFile());
}
IEnumerator DownloadFile()
{
var uwr = new UnityWebRequest("http://localhost:8080/300dzz5g.jumpw.com/wxdev/", UnityWebRequest.kHttpVerbGET);
string path = Path.Combine(Application.dataPath, "/md5.txt");
uwr.downloadHandler = new DownloadHandlerFile(path);
yield return uwr.SendWebRequest();
if (uwr.result != UnityWebRequest.Result.Success)
Debug.LogError(uwr.error);
else
Debug.Log("File successfully downloaded and saved to " + path);
}
}
成功! perfect!