BizTalk Server Orchestration - Reading and writing to a file in an orchestration

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > August 2005 > Reading and writing to a file in an orchestration





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Reading and writing to a file in an orchestration
Jeff Wessling

2005-08-26, 2:50 am

I'm trying to "write to" and "read from" a file in my orchestration, but
keep getting an XLANG "Cannot access a closed file" errors. I'm using this
code in and Expression shape:


fs = System.IO.File.Open(sFilePath, System.IO.FileMode.OpenOrCreate,
System.IO.FileAccess.ReadWrite);
fsw = new System.IO.StreamWriter(fs);
fsr = new System.IO.StreamReader(fs);

fsw.WriteLine(sBatchName);
fsw.Close();

while (sTemp != null)
{
sTemp=fsr.ReadLine();
...
}
fsr.Close();


All the variables are defined in the orchestation. I've tried not closing
fsw and fsr, but that just results in a different error about fs "object
FileStream is not serializable". Does anyone have a better way to do this
(ie one that doesn't cause errors)?

Thanks,
Jeff



Scott Colestock

2005-08-26, 5:55 pm

When you close a StreamWriter (see fsw.Close below) you are closing the
underlying stream as well (hence a subsequent read attached to that stream
will fail.)

Scott Colestock
www.traceofthought.net


"Jeff Wessling" <jeff.wessling@qualifacts.com> wrote in message
news:uh%23y2MfqFHA.2624@TK2MSFTNGP10.phx.gbl...
> I'm trying to "write to" and "read from" a file in my orchestration, but
> keep getting an XLANG "Cannot access a closed file" errors. I'm using this
> code in and Expression shape:
>
>
> fs = System.IO.File.Open(sFilePath, System.IO.FileMode.OpenOrCreate,
> System.IO.FileAccess.ReadWrite);
> fsw = new System.IO.StreamWriter(fs);
> fsr = new System.IO.StreamReader(fs);
>
> fsw.WriteLine(sBatchName);
> fsw.Close();
>
> while (sTemp != null)
> {
> sTemp=fsr.ReadLine();
> ...
> }
> fsr.Close();
>
>
> All the variables are defined in the orchestation. I've tried not closing
> fsw and fsr, but that just results in a different error about fs "object
> FileStream is not serializable". Does anyone have a better way to do this
> (ie one that doesn't cause errors)?
>
> Thanks,
> Jeff
>
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com