如何在任何类型的文件上添加字符串,然后检测该字符串中的特定单词,然后使用c#.net从文件中删除该特定单词 [英] how to add a string on any type of file and then detect the specific word from that string and then delete that specific word from files using c#.net

查看:113
本文介绍了如何在任何类型的文件上添加字符串,然后检测该字符串中的特定单词,然后使用c#.net从文件中删除该特定单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个应用程序,首先我添加一个字符串,如试试但不要哭我想将此字符串添加到我的电脑上的某些文件然后我想删除但是我想要如果文件中包含该单词,则检查文件中是否存在该文件包含该单词的文件

I want to create an application on which first i have add one string like "Try Try But Don't Cry" i want to add this string to some files on my pc and then I want to delete "But" i want to check the files for that certain word weather that files contains that word or not if the files contains that word delete that word from files

推荐答案

所以你模拟病毒和病毒扫描程序?你不能在原帖中说出来吗?



你的模拟非常天真。病毒不会感染数据文件。它们会感染可执行文件。



使用二进制文件时,您无法使用StreamReader / Writer,因为它会尝试将所有内容解释为文本。您必须使用FileStream及其方法来读取/写入文件,但现在您不是要查找文本字符串,而是查找构成病毒签名的字节流。
So you simulating a virus and a virus scanner? You couldn't say that in your original post?

Your simulation is quite naive. Viruses don't infect data files. They infect executable files.

With binary files, you cannot use a StreamReader/Writer as it tries to interpret everything as text. You have to use the FileStream and its methods to read/write the file, but now you're not looking for a text string but a stream of bytes that makes up your virus signature.

这篇关于如何在任何类型的文件上添加字符串,然后检测该字符串中的特定单词,然后使用c#.net从文件中删除该特定单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆