C#读写文件范例

    xiaoxiao2022-06-27  210

    class Program { static void Main(string[] args) { string strLine = string.Empty; FileStream filein = new FileStream("D:/zihao-record/keyan.txt", FileMode.Open); FileStream fileout = new FileStream("D:/zihao-record/keyan_out.txt", FileMode.Create); StreamReader reader = new StreamReader(filein); StreamWriter writer = new StreamWriter(fileout); HashSet<string> strContains = new HashSet<string>(); while (!reader.EndOfStream) { strLine = reader.ReadLine(); strLine = strLine.Trim().ToString(); string[] sArray = strLine.Split(new char[1]{'/'}); foreach (var strSon in sArray) { if (strSon.Contains("Currency")) { continue; } if (strSon == "") { continue; } string[] sArraySon = strSon.Split(new char[1] {':'}); string itemType = sArraySon[1]; string itemID = sArraySon[2]; if (strContains.Contains(itemType + itemID)) { continue; } string strOut = $"GMAddStoreItem itemType={itemType} itemConfigId={itemID} count=500000000 bind=true"; writer.WriteLine(strOut); strContains.Add(itemType + itemID); } } writer.WriteLine("xxxxxxxx"); filein.Close(); writer.Close(); Console.WriteLine(); } }

     


    最新回复(0)