Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 831369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:11:35+00:00 2026-05-15T04:11:35+00:00

I want to send a binary file to .net c# component in the following

  • 0

I want to send a binary file to .net c# component in the following xml format

<BinaryFileString fileType='pdf'>
    <!--binary file data string here-->
</BinaryFileString>

In the called component I will use the above xml string and convert the binary string received within the BinaryFileString tag, into a file as specified by the filetype=” attribute. The file type could be doc/pdf/xls/rtf

I have the code in the calling application to get out the bytes from the file to be sent. How do I prepare it to be sent with xml tags wrapped around it? I want the application to send out a string to the component and not a byte stream. This is because there is no way I can decipher the file type [pdf/doc/xls] just by looking at the byte stream. Hence the xml string with the filetype attribute. Any ideas on this?

method for extracting Bytes below

   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;

Thanks.

Edit:

Just to clarify why I am using an xml string rather than setting properties on my component. Actually my calling app is trying to simulate how Siebel will call my component.
http://download.oracle.com/docs/cd/E05553_01/books/eScript/eScript_JSReference244.html#wp1014380
Im not sure if Siebel can set my components properties as I need it to. So Im working on the angle of it sending the data in xml.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:11:35+00:00Added an answer on May 15, 2026 at 4:11 am

    Base64 representation is universaly used to represent binary data.

    public void EncodeWithString() {
        System.IO.FileStream inFile;     
        byte[] binaryData;
    
        try {
            inFile = new System.IO.FileStream(inputFileName,
                                              System.IO.FileMode.Open,
                                              System.IO.FileAccess.Read);
            binaryData = new Byte[inFile.Length];
            long bytesRead = inFile.Read(binaryData, 0,
                                        (int)inFile.Length);
            inFile.Close();
        }
        catch (System.Exception exp) {
            // Error creating stream or reading from it.
            System.Console.WriteLine("{0}", exp.Message);
            return;
        }
    
        // Convert the binary input into Base64 UUEncoded output.
        string base64String;
        try {
             base64String = 
                System.Convert.ToBase64String(binaryData, 
                                              0,
                                              binaryData.Length);
        }
        catch (System.ArgumentNullException) {
            System.Console.WriteLine("Binary data array is null.");
            return;
        }
    
        // Write the UUEncoded version to the XML file.
        System.IO.StreamWriter outFile; 
        try {
            outFile = new System.IO.StreamWriter(outputFileName,
                                        false,
                                        System.Text.Encoding.ASCII);             
            outFile.Write("<BinaryFileString fileType='pdf'>");
            outFile.Write(base64String);
            outFile.Write("</BinaryFileString>");
            outFile.Close();
        }
        catch (System.Exception exp) {
            // Error creating stream or writing to it.
            System.Console.WriteLine("{0}", exp.Message);
        }
    }
    

    At the receiving end you can reverse this and get back original file content as mentioned below.

            // Convert the Base64 UUEncoded input into binary output.
            byte[] binaryData;
            try {
                binaryData = 
                    System.Convert.FromBase64String(base64String);
            }
            catch (System.ArgumentNullException) {
                System.Console.WriteLine("Base 64 string is null.");
                return;
            }
            catch (System.FormatException) {
                System.Console.WriteLine("Base 64 string length is not " +
                    "4 or is not an even multiple of 4." );
                return;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.