none
c# create binary file, can not read from AS400 RRS feed

  • Question

  • i used BinaryWriter

    using (BinaryWriter b = new BinaryWriter(File.Open("file_num", FileMode.Create), Encoding.GetEncoding(37)))
                {

                    for (int i = 0; i < 17; i++)
                        b.Write(i);
                }
    i also used BinaryFormatter
                using (FileStream fs =  new FileStream("DataFile", FileMode.Create))// FileStream("DataFile.dat", FileMode.Create)
                {
                    Hashtable addresses = new Hashtable();
                    addresses.Add("Jeff", "123 Main Street, Redmond, WA 98052");
                    addresses.Add("Fred", "987 Pine Road, Phila., PA 19116");
                    addresses.Add("Mary", "PO Box 112233, Palo Alto, CA 94301");
                    BinaryFormatter formatter = new BinaryFormatter();
                    string s = "this is a test";
                    formatter.Serialize(fs, addresses);
                }

    whatever i try AS400 can not read the binary file (can open the file, but it are unreadable Characters)

    why ??????????? how???????????????

    Friday, January 11, 2013 2:39 AM

Answers

  • Maybe AS400 expects simple ASCII strings? You can write them like this:

    using (StreamWriter sw = new StreamWriter("DataFile", false, Encoding.ASCII))
    {     sw.WriteLine("123 Main Street, Redmond, WA 98052");     // . . . }


    By the way, what is AS400?
    Friday, January 11, 2013 1:08 PM
  • iSeries (AS400) native encoding is EBSIDEC, however this is often translated in the connector so that a PC is presented with ASCII or UTF8 encoded data.

    You should also tell us how you establish the connection since some kind of connector is required (could be from ClientAccess, ODBC, or 3rd party connector).


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, January 14, 2013 4:00 PM
    Moderator

All replies

  • Maybe AS400 expects simple ASCII strings? You can write them like this:

    using (StreamWriter sw = new StreamWriter("DataFile", false, Encoding.ASCII))
    {     sw.WriteLine("123 Main Street, Redmond, WA 98052");     // . . . }


    By the way, what is AS400?
    Friday, January 11, 2013 1:08 PM
  • You're better off using text.  But either way, both your Windows box and your AS400 need to agree on EXACTLY what the file will look like. 

    Binary is will be more compact, but you need to make sure both machines agree on the way numeic data is represented (Big Endian vs Little Endian)  You also need to define the file format more rigidly so that both sides know where each bit of data lies.

    Text will be human readable, and offers a bit more flexibility.


    This signature unintentionally left blank.

    Monday, January 14, 2013 11:26 AM
  • iSeries (AS400) native encoding is EBSIDEC, however this is often translated in the connector so that a PC is presented with ASCII or UTF8 encoded data.

    You should also tell us how you establish the connection since some kind of connector is required (could be from ClientAccess, ODBC, or 3rd party connector).


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, January 14, 2013 4:00 PM
    Moderator
  • AS/400 is the mainframe system series of IBM.
    Tuesday, January 15, 2013 10:07 AM
    Answerer