mardi 4 août 2015

How do i strip a section of a folder in C

I have a script that reads email in Outlook for Web, generates the folder structure by parsing the subject line, then downloads the file into the folder it just created.

    foreach (Item myItem in findResults.Items)
            {
                if (myItem is EmailMessage)
                {
                    Console.WriteLine((myItem as EmailMessage).Subject);
                    string strSubject = (myItem as EmailMessage).Subject;
                    string[] strDelimiters = { " - ", " - " };
                    string []strTemp;
                    string []strFolders;
                    string strFileUrl;
                    strTemp = strSubject.Split(strDelimiters, StringSplitOptions.None);

                    strDelimiters[0] = " "; strDelimiters[1] = " ";
                    strFolders = strTemp[1].Split(strDelimiters, 2, StringSplitOptions.None);
                    strFolders[1] = strFolders[1].Replace('>', '_');

so when it parses a subject like this:

    Falcon - MCCP_1507_031_AA en-US>de-DE - **Task file uploaded** - 20178544 -  -  - 10213-022XX1 - FF

it produces a folder structure like this:

    \MCCP_1507_031_AA\en-US_de-DE\

My question is: what should I add to this to this code in order for it to drop the two letters after the last underscore (in this particular case _AA)? I would like the folder structure to look like:

    \MCCP_1507_031\en-US_de-DE\

This is my first post, I hope I did everything correctly. Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire