带有XML的base64字符串中的字符无效

时间:2013-01-31 01:14:03

标签: c# xml base64

我收到,我很伤心地说,我不知道很多有关处理64base字符串错误。目前我已经将此错误跟踪到这行代码:

byte[] jobData = Convert.FromBase64String(base64JobData);

这是我的XML,它被传递到base64JobData,但我似乎无法找到任何应​​该抛出此错误的内容。

<?xml version="1.0" encoding="utf-16"?>
<JobItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SiteServerItemShareCollection" JobName="0005_Hi" JobTargetResultId="2a59cf11-c58e-4cdc-80e8-7b4c70b940dc" JobId="5a79a30f-3250-4401-b181-f6e5f16fe5ef" JobItemType="NetworkShare" JobProcessWorkflowId="9834e3a5-b508-405f-ad5b-d8c9d1837982" Priority="1" CallbackConversationId="fb501b7b-cd43-4883-bbc7-5a356e1dd030" IsAudit="false" IsRemediation="false" IsArchive="true" IsPreview="false" ReportOnNonResponsiveData="false" CustodianId="00000000-0000-0000-0000-000000000000" IsCompleted="false" HasCredentials="true" MinSecondsBetweenAttempts="600" UseRedirectedAcquisition="false" IsSerialProcessing="false" CanPhoneHome="false" AgentGuid="00000000-0000-0000-0000-000000000000" DynamicIPLocality="false" TaskId="00000000-0000-0000-0000-000000000000">
<CollectionItemQueue ItemId="2a59cf11-c58e-4cdc-80e8-7b4c70b940dc" CollectionId="5a79a30f-3250-4401-b181-f6e5f16fe5ef" CollectionType="NetworkShare" Name="0005_Hi" ReferenceItemId="00000000-0000-0000-0000-000000000000" CollectionStatus="0">
  <AssetCollectionStartDate xsi:nil="true" />
  <PrescanStartDate xsi:nil="true" />
  <LastCollectedFileSize xsi:nil="true" />
  <NumberFilesCollected xsi:nil="true" />
  <FilesCollectedSize xsi:nil="true" />
  <CurrentFileSize xsi:nil="true" />
  <TotalPossibleFilesToCollect xsi:nil="true" />
  <TotalPossibleFileBytesToCollect xsi:nil="true" />
</CollectionItemQueue>
<RunCollectionPreScan>false</RunCollectionPreScan>
<FileTransferRetryDelayInSeconds>900</FileTransferRetryDelayInSeconds>
<FileTransferRetryAttempts>3</FileTransferRetryAttempts>
<AssetCollectionStartDate xsi:nil="true" />
<PrescanStartDate xsi:nil="true" />
<LastCollectedFileSize xsi:nil="true" />
<NumberFilesCollected xsi:nil="true" />
<FilesCollectedSize xsi:nil="true" />
<CurrentFileSize xsi:nil="true" />
<TotalPossibleFilesToCollect xsi:nil="true" />
<TotalPossibleFileBytesToCollect xsi:nil="true" />
<JobTargetName>\\10.10.200.222\Evidence</JobTargetName>
<JobTargetId>fd0d6e98-7227-4589-b578-a8f0a88955c2</JobTargetId>
<JobResultId>00000000-0000-0000-0000-000000000000</JobResultId>
<FiltersXML>&lt;Filter SystemFiles="false" UnusedDiskArea="false" VolumeSlack="false" CollectArchiveContentOnly="true" CollectEncryptedFiles="false" UsePhysicalDrives="false" UseSearchWithAgent="false" UseSearchWithServer="false" AutoDrillDown="false" CollectNoExtensionFiles="false" IncludeDeletedFiles="false" SmartFileIdentification="false" xmlns="http://FilterSchema" /&gt;</FiltersXML>
<ResponsiveFilePath>\\10.10.200.222\E$\Cases\Jobs\Test\2013-01-30 15.46.46\Item_10.10.200.222Evidence\1</ResponsiveFilePath>
<CollectionAttemptBeginTime xsi:nil="true" />
<CollectionAttemptEndTime xsi:nil="true" />
<CollectAsCredentials />
<Expiration>2013-03-01T15:46:45.797</Expiration>
<CollectionEncryption>
  <CollectionId>5a79a30f-3250-4401-b181-f6e5f16fe5ef</CollectionId>
  <EncryptionType>None</EncryptionType>
<CertificateId>00000000-0000-0000-0000-000000000000</CertificateId>
</CollectionEncryption>
</JobItem>

有没有一种简单的方法可以找出这个xml字符串中有问题的字符是什么?或者一种可以帮助我找到失败原因的工具。

1 个答案:

答案 0 :(得分:0)

我认为你的问题可能令人困惑,或者对函数的行为有误解。这个函数是转换FROM base64,所以如果你给它上面的XML提供,那将无法工作。该函数期望base64编码的字符串。

以下是MS的链接 - frombase64string

哪种状态,“将指定的字符串转换为等效的8位无符号整数数组,将二进制数据编码为基数为64的数字。”

参数字符串“s” - s由base-64数字,空格字符和尾随填充字符组成。从零开始的基数为64的数字是大写字母“A”到“Z”,小写字母“a”到“z”,数字“0”到“9”,符号“+”和“/” ”