What I'm trying to do is read all the text in a file, and if it contains the word "Share", do a regular expression. Here is the code:
DirectoryInfo dinfo = new DirectoryInfo(@"C:\Documents and Settings\g\Desktop\123"); FileInfo[] Files = dinfo.GetFiles("*.txt"); foreach (FileInfo filex in Files) { string contents = File.ReadAllText(filex.FullName); string matchingcontants = "Share"; if (contents.Contains(matchingcontants)) { string sharename = Regex.Match(contents, @"\+(\S*)(.)(.*)(.)").Groups[3].Value; File.AppendAllText(@"C:\sharename.txt", sharename + @"\r\n"); } }
When I debug, I get ... content = "\ r \ 0 \ n \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 = \ 0 \ r \ 0 \ n \ 0+ \ 0S \ 0h \ 0a \ 0r \ 0e \ 0 \ 0 \\ 0 \\ 0j \ 05 \ 02 \ 0 \\ 0w \ 0w \ 0w \ 0_ \ 0O \ 0n \ 0t \
\ 0S \ 0h \ 0a \ 0 \ 0e \
Do not share. Any hints? tips or suggestions?
user222427
source share