views:

132

answers:

2

I have something like this:

"Content-Transfer-Encoding: base64

UEsDBBQABgAIAAAAIQDfz5sukgEAAJQGAAATANwBW0NvbnRlbnRfVHlwZXNdLnhtbCCi2AEooAAC
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

That ends with a line like this:

"DwAPAPADAAA7KQAAAAA="

It is a file with MIME format, i thought about putting "base64\r\n" and it will end when it finds "=", but i am missing the way to cut that selection that from the text file to put it in another one. I am trying with streamreader and streamwriter but with no luck so far.

+1  A: 

Try using:

yourFileText.split("\r\n\r\n");

It will return an array in which each item is a paragraph of text.

I Hope that helps.

cazlab
A: 

I need to cut that MIME from a email that will change from time to time i need to code it so it can distinguish the MIME part from the rest and copy that in a text file so i can decode it.

I tried before to use split, but when i used it with ("\r\n\r\n") it says that it has some invalid arguments.

Before this, i used the ReadAllLines to choose fields separated with a ";" for example like this:

string[] lines2 = System.IO.File.ReadAllLines(@"../../../mime.txt");
IEnumerable<string> query2 =
            from line2 in lines2
            let w = line2.Split("\r\n\r\n")
            where line2.Contains("$") & line2.EndsWith("ain")
            select w[0] + ";" + w[1] + ";" + w[2] + ";" + w[3] + ";" + w[4] + ";";
System.IO.File.WriteAllLines(@"../../../Bloq.csv", query2.ToArray());

And it worked just fine, i tried to use that but because i will get all the lines corresponding to the MIME i thought that it wouldn't work in my case.

Alexander Berner
Clever, glad it ended up working :)
cazlab