Setting The Output File Stream

Index

    Setting The Output File Stream

    Creating an EDI document is easy with the EDIDocument component. The EDIDocument component contains a constructor that accepts a FileStream object Initializing a FileStream object and passing it to the EDIDocument constructor will cause any EDI document generated to be written to that specific stream.

    Example

    // Create a filestream object
    FileStream myStream = new StreamWriter(“C:\\edi.txt”);
     
    // Instantiate an instance of EDIDocument and set the filestream parameter
    EDIDocument sampleEDIFile = new EDIDocument(myStream);

    // Create an interchange loop. This loop will contain all other loops in the EDI structure
    Loop interchangeHeaderLoop = new Loop(Interchange Header”);

    // Add the interchange loop to the EDI document
    sampleEDIFile.Loops.Add(interchangeHeaderLoop);

    // Generate the EDI file
    sampleEDIFile.GenerateEDIFile();
    You can also explicitly set the FileStream property of EDIDocument.
    in EDI Document
    Did this article answer your question?