Reading and writing to a file in an orchestration
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > BizTalk Server > BizTalk Server Orchestration > Reading and writing to a file in an orchestration




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Reading and writing to a file in an orchestration  
Jeff Wessling


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-26-05 07: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








[ Post a follow-up to this message ]



    Re: Reading and writing to a file in an orchestration  
Scott Colestock


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-26-05 10: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
>
>
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:20 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register