c# - How the edit a specified file (kinda text) with setting only the end of the file name -
my code looks this:
string text = file.readalltext("test.txt"); text = text.replace("some text", "new value"); file.writealltext("test.txt", text);
i want edit 2 words, not one:
- from
side
*side
- and
barcode
*barcode
also there solution find file end of name instead of full name? because file name different ends string "_abc.desc"
you can find file end of it's name
string partialname = "text"; // ending part of file name directoryinfo hddirectoryinwhichtosearch = new directoryinfo(@"d:\"); fileinfo[] filesindir = hddirectoryinwhichtosearch.getfiles("*" + partialname + ".*"); // files matched name show in filesindir foreach (fileinfo foundfile in filesindir) { string fullname = foundfile.fullname; string text = file.readalltext(fullname);// here text }
Comments
Post a Comment