We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Folder DisplayName contains backslash

Hi,

we’re copying PST file structure from file A to file B while we try to preserve the folder structure. That includes the RootFolder name of the PST (I do know this isn’t visible to the user, but we require that).

Testing with a German ANSI PST file we get the name of the root folder containing unexpected backslash.

Here is a sample code we’re using:

static void Main(string[] args)
{
new License().SetLicense(“Aspose.Email.lic”);
<span style="color:blue;">if</span> (args.Length != 1)
{
    <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"Usage: </span><span style="color:mediumseagreen;">{0}</span><span style="color:#a31515;"> <source pst file>"</span>, <span style="color:#2b91af;">AppDomain</span>.CurrentDomain.FriendlyName);
    <span style="color:blue;">return</span>;
}

<span style="color:blue;">using</span> (<span style="color:blue;">var</span> pst = <span style="color:#2b91af;">PersonalStorage</span>.FromFile(args[0], <span style="color:blue;">false</span>))
{
    <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"PST File [</span><span style="color:mediumseagreen;">{0}</span><span style="color:#a31515;">] - [</span><span style="color:mediumseagreen;">{1}</span><span style="color:#a31515;">]"</span>, args[0], pst.IsUnicode ? <span style="color:#a31515;">"Unicode"</span> : <span style="color:#a31515;">"ANSI"</span>);

    GetFolderNames(pst.RootFolder, pst.IsUnicode);
    GetFolderNames(pst.GetPredefinedFolder(<span style="color:#2b91af;">StandardIpmFolder</span>.DeletedItems), pst.IsUnicode);
    GetFolderNames(pst.GetPredefinedFolder(<span style="color:#2b91af;">StandardIpmFolder</span>.Inbox), pst.IsUnicode);
}

}

private static void GetFolderNames(FolderInfo folder, bool isUnicode)
{
if (folder == null)
{
return;
}

<span style="color:blue;">var</span> displayName = folder.DisplayName;
<span style="color:blue;">var</span> containsBackslash = displayName.Contains(<span style="color:#a31515;">@"\"</span>);
<span style="color:blue;">var</span> displayNameProp = isUnicode ? <br>                          folder.Properties[<span style="color:#2b91af;">MapiPropertyTag</span>.PR_DISPLAY_NAME_W] : <br>                          folder.Properties[<span style="color:#2b91af;">MapiPropertyTag</span>.PR_DISPLAY_NAME_A];

<span style="color:blue;">var</span> convertedAscii = <span style="color:#2b91af;">Encoding</span>.ASCII.GetString(displayNameProp.Data);
<span style="color:blue;">var</span> convertedDefault = <span style="color:#2b91af;">Encoding</span>.Default.GetString(displayNameProp.Data);

<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"PST Folder [</span><span style="color:mediumseagreen;">{0}</span><span style="color:#a31515;">] - [</span><span style="color:#ff007f;">\\</span><span style="color:#a31515;"> </span><span style="color:mediumseagreen;">{1}</span><span style="color:#a31515;">found] - ASCII [</span><span style="color:mediumseagreen;">{2}</span><span style="color:#a31515;">] - Default [</span><span style="color:mediumseagreen;">{3}</span><span style="color:#a31515;">]"</span>, <br>                      displayName, containsBackslash ? <span style="color:blue;">string</span>.Empty : <span style="color:#a31515;">"NOT "</span>, <br>                      convertedAscii, convertedDefault);

}

The output of that looks like this:


PST File [ansi_german_file.pst] - [ANSI]

PST Folder [Oberste Ebene des Pers’F6nlichen Ordners] - [\ found] - ASCII [Oberste Ebene des Pers?nlichen Ordners] - Default [Oberste Ebene des Persönlichen Ordners]

PST Folder [Gel’F6schte Objekte] - [\ found] - ASCII [Gel?schte Objekte] - Default [Gelöschte Objekte]

PST Folder [Inbox] - [\ NOT found] - ASCII [Inbox] - Default [Inbox]

We're not sure how the DisplayName is retrieved but I suspect it shouldn't contain backslash as it's separator. Also, retrieval of the value directly from the MapiProperty gives better results (especially the "Default" one). Is this something that is "codepage" related?

I'm attaching the ANSI sample PST file (in ZIP).

Best regards,
Michal

Hi Michal,


Thank you for writing to Aspose support team.

I have observed the issue by executing the sample code and have logged it as EMAILNET-34796 in our bug tracking system for further analysis by the product team. I shall write he as soon as some feedback is received in this regard.

The issues you have found earlier (filed as EMAILNET-34796) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.