我正在尝试在 C# 中同时读取和写入文件。我在这里和 MSDNA 中阅读了许多主题,但似乎没有一个能满足我的需求。我的文件有一系列用逗号分隔的数字。确切地说是大量的数字。我的数据中的示例行是这样的
-0.1171695,0.03270377,2.420116,-0.02128719,0.9612453,0.2460478,-0.1225349,-0.110185,0.07739609,2.500247,-0.2783474,-0.06909045,-0.01818598,0.9578197,-0.1089995,0.456151,2.639686,0.3486561,-0.0008622027,-0.002657401,0.9372466,-0.1170361,0.6441286,2.674476,0.08662115,0.001171953,-0.01347759,0.9961495,-0.2623751,0.3104511,2.600713,-0.002028131,0.004831213,0.9220369,-0.3870664,-0.3145202,0.123338,2.49155,0.217727,0.4528476,-0.2009471,0.8409188,-0.2771441,-0.07509593,2.299996,0.2185546,3.817581E-09,7.635163E-09,0.9758247,-0.2690773,-0.1254997,2.259336,-0.02814693,0.0009682054,-0.03436448,0.9990125,0.01672855,0.3196935,2.572941,0.001961287,0.005368799,0.9392719,0.3431264,0.08505877,0.1033191,2.450031,0.1364797,-0.3903133,0.161962,0.8959894,0.03953359,-0.08940583,2.255897,0.2523192,7.699712E-09,0,0.967644,0.01856858,-0.1507191,2.211281,0.004362902,0.0004109977,0.09378911,0.9955825,-0.1821601,-0.03123568,2.403718,4.035548E-09,-3.067017E-07,0.9231187,-0.384515,-0.2238743,-0.4083549,2.266029,-0.05534944,0.02699615,-0.3286877,0.9424288,-0.2095885,-0.7422835,2.178757,-0.06393463,-0.003723484,-0.0580211,0.9962591,-0.2166772,-0.7653325,2.087598,0.5079094,0.03407073,-0.05760901,0.8588064,-0.05478298,-0.01793054,2.37413,8.070093E-09,-3.066635E-07,0.9232336,0.3842392,0.004473582,-0.3737353,2.252681,-0.09306445,-0.04594634,0.3224528,0.9408783,0.004849254,-0.7096405,2.178587,-0.03546751,0.003154774,0.08854229,0.9954358,-0.005173458,-0.7367281,2.088935,0.5053017,0.02486493,-0.04239483,0.861542,63507242650167
它实际上在写字板中占用了 24 行。每一行。我想要做的是转到每行的最后一个数字,对其进行更改,然后将其保存回文件中。我发现的所有同步编写器阅读器源代码都在使用 append。我不希望在文件末尾追加。我希望从每行中获取最后一个数字,然后将修改后的数据放回原处。我希望其余数据保持不变。我该怎么做?