//新的txt
var tempFile = _iHostEnvironment.WebRootPath + "mgc1.txt";
File.AppendText(tempFile);
//查找不等于ceshi的数据
var linesToKeep = File.ReadLines(_iHostEnvironment.WebRootPath + "mgc.txt").Where(x => x !=“ceshi”);
//写到新的txt
File.WriteAllLines(tempFile, linesToKeep);
//删除旧的txt
File.Delete(_iHostEnvironment.WebRootPath + "mgc.txt");
File.Move(tempFile, _iHostEnvironment.WebRootPath + "mgc.txt");