首页 > 其他 > 详细

读取本地txt配置文件,获取ServerIP

时间:2017-08-14 13:55:08      阅读:342      评论:0      收藏:0      [点我收藏+]

1.

技术分享

 

2.

 技术分享

 

3.

 技术分享

 

4.

技术分享

5.

技术分享

6.

技术分享

 

7.

private void CreateTxt(string filename)
{
if (filename == "")
{
Debug.LogError("请输入文件名");
return;
}

string filePath = Application.dataPath + "/StreamingAssets" + "/" + filename;
if (!File.Exists(filePath))
{
FileStream fs1 = new FileStream(filePath, FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine("hhhhhh--");//开始写入值
sw.Close();
fs1.Close();
//Console.WriteLine("txt no exit");
}
}

private void ReadTxt(string filename)
{
string filePath = Application.dataPath + "/StreamingAssets" + "/" + filename;
if (!File.Exists(filePath))
{
Debug.LogError("文件不存在");
return;
}
else
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string fileContent = sr.ReadToEnd();
readTxtContent.text = fileContent;
sr.Close();
fs.Close();
}
}

private void WriteTxt(string filename)
{
string filePath = Application.dataPath + "/StreamingAssets" + "/" + filename;
if (!File.Exists(filePath))
{
Debug.LogError("文件不存在");
return;
}
else
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(writeTxtContent.text);//开始写入值
sw.Close();
fs.Close();
}
}

 

读取本地txt配置文件,获取ServerIP

原文:http://www.cnblogs.com/Study02/p/7357310.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!