如何跳过文本文件中行首包含分号的行?我目前正在读取一个包含服务器名称的文本文件,效果很好。我想在行首添加一个分号以将其注释掉,以防服务器进入维护模式。
最佳答案
var lines = File.ReadAllLines( path );
foreach( var line in lines )
{
if( line.StartsWith( ";" ) )
{
continue;
}
else
{
// do your stuff
}
}
关于c# - 跳过文本文件中包含分号的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7276158/