在 C# 中,如何在文件共享中搜索特定 Word 的 csv 文件,而无需手动打开它。如果这个词存在“做某事”,如果不存在“做其他事”。我想将此步骤包含在现有的 SQL Server 作业中。
问问题
311 次
1 回答
2
如果不读取文件,则无法扫描文件内容:
string content = File.ReadAllText(path);
if (content.Contains("word"))
{
// Text is found
}
else
{
// Text is not found
}
您可以考虑使用正则表达式:
if (Regex.IsMatch(content, @"\bword\b", RegexOptions.IgnoreCase))
{
// Word is found
}
else
{
// Word is not found
}
于 2013-05-29T21:08:14.183 回答