C# 我想读写一个C语言的文件#

C# 我想读写一个C语言的文件#,c#,file,C#,File,这是我没有文件的代码 static void Main(string[] args) { // BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable; BluetoothClient bc = new BluetoothClient(); BluetoothDeviceInfo[] devs = bc.DiscoverDevicesInRange(); foreach (BluetoothDeviceIn

这是我没有文件的代码

static void Main(string[] args)
{
    // BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
    BluetoothClient bc = new BluetoothClient();
    BluetoothDeviceInfo[] devs = bc.DiscoverDevicesInRange();
    foreach (BluetoothDeviceInfo d in devs)
    {
        System.Console.WriteLine(d.DeviceName);
    }

    System.Console.WriteLine("finish");
    System.Console.ReadLine();
}
而不是行
System.Console.WriteLine(d.DeviceName)
我想把那部分写进一个文件

之后,我需要在该文件上循环,对于该文件中的每个设备名称,我将在另一个文件中搜索相应的输出。关于如何循环和搜索文件的提示对于该部分就足够了

谢谢。

您可以将其用作精确的下拉列表(但您需要在文本中附加Environment.NewLine)


如果文件在foreach循环之前存在,请确保删除该文件,可能会提示用户根据您的要求进行确认。

whao-谷歌必须再次被破坏:)Rene-您在删除的答案中的评论说明了一切-希望我能在删除您的答案时为您投票,因为OP不会费心跟踪您的建议链接