int index = this.lvSets.SelectedItems[0].Index; FileStream fs = new FileStream("iteminfo.txt", FileMode.Create); StreamWriter sw = new StreamWriter(fs); switch (setName) { case "套餐A": sw.WriteLine("检查项目名称:{0}", setA.Items[index].Name); sw.WriteLine("功能描述:{0}", setA.Items[index].Description); sw.WriteLine("单价:{0}元", setA.Items[index].Price); break; case "套餐B": sw.WriteLine("检查项目名称:{0}", setB.Items[index].Name); sw.WriteLine("功能描述:{0}", setB.Items[index].Description); sw.WriteLine("单价:{0}元", setB.Items[index].Price); break; } sw.WriteLine("检查项目名称:{0}", setA.Items[index].Name); sw.WriteLine("功能描述:{0}", setA.Items[index].Description); sw.WriteLine("单价:{0}元", setA.Items[index].Price); break; case "套餐B": sw.WriteLine("检查项目名称:{0}", setB.Items[index].Name); sw.WriteLine("功能描述:{0}", setB.Items[index].Description); sw.WriteLine("单价:{0}元", setB.Items[index].Price); break; }