相关疑难解决方法(0)

如何在xml字符串中发送二进制数据

我想以下面的xml格式将二进制文件发送到.net c#组件

<BinaryFileString fileType='pdf'>
    <!--binary file data string here-->
</BinaryFileString>
Run Code Online (Sandbox Code Playgroud)

在被调用的组件中,我将使用上面的xml字符串并将BinaryFileString标记中接收的二进制字符串转换为filetype =''属性指定的文件.文件类型可以是doc/pdf/xls/rtf

我在调用应用程序中有代码从要发送的文件中取出字节.如何准备将其与包裹在其周围的xml标签一起发送?我希望应用程序向组件发送字符串而不是字节流.这是因为我无法通过查看字节流来解密文件类型[pdf/doc/xls].因此具有filetype属性的xml字符串.有什么想法吗?

提取下面的字节的方法

   FileStream fs = new FileStream(_filePath, FileMode.Open, FileAccess.Read);
   using (Stream input = fs)
   {
      byte[] buffer = new byte[8192];
      int bytesRead;
      while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
      {}
   }
   return buffer;
Run Code Online (Sandbox Code Playgroud)

谢谢.

编辑:

只是为了澄清为什么我使用xml字符串而不是在我的组件上设置属性.实际上我的调用应用程序试图模拟Siebel如何调用我的组件. http://download.oracle.com/docs/cd/E05553_01/books/eScript/eScript_JSReference244.html#wp1014380 我不确定Siebel是否可以根据需要设置我的组件属性.所以我正在研究它在xml中发送数据的角度.

c# binary filestream

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

binary ×1

c# ×1

filestream ×1