using UnityEngine;
using System.Collections;
using System.Xml;
using System;
using System.Text;
using System.IO;
public class Weather : MonoBehaviour
{
XmlDocument xmlDoc;
// Use this for initialization
void Start ()
{
xmlDoc = new XmlDocument ();
StartCoroutine (DownXml ());
}
// Update is called once per frame
void Update ()
{
}
IEnumerator DownXml ()
{
WWW www = new WWW ("http://flash.weather.com.cn/wmaps/xml/dalian.xml");
yield return www;
CreateFile (Application.dataPath, "myXml.xml", www.text);
}
void CreateFile (string path, string name, string info)
{
// 文件流信息
StreamWriter sw;
FileInfo t = new FileInfo (path + "//" + name);
if (!t.Exists) {
// 如果此文件不存在则创建
sw = t.CreateText ();
// 以行的形式写入信息
sw.WriteLine (info);
} else {
// 如果此文件存在则打开
sw = t.AppendText ();
}
// 关闭流
sw.Close ();
// 销毁流
sw.Dispose ();
}
void DeleteFile (string path, string name)
{
File.Delete (path +
【Unity】将一串字符串保存到Unity中,保存成任意格式
最新推荐文章于 2025-04-27 09:03:47 发布