Solved

Filestream C#

Posted on 2012-03-14
1
315 Views
Last Modified: 2012-03-29
Hi Experts,

Please give me some suggesstion for below,

I have batch process for which I will get  a txt file as a input which will have 150k byte length or lesser. The txt file will have a header line like "date, time etc...." as one line.
and remaining will  as xml tags.
Before the xml tag starts, I will have 20 byte string like "A0000001-0000001-1-4" which is
Auto Number + unique seq# + split xml seq # + total split xmls.
If the txt file is 150k then the input txt fiel is splitting the string to 5.
so in between xml i  will be having
A0000001-0000001-1-5
A0000001-0000001-2-5
A0000001-0000001-3-5
A0000001-0000001-4-5
A0000001-0000001-5-5

This is used to spllit the string in the iput file to 5 parts for some reason.
I am using File stream,  to open the file and do my operations.

Now, i want to read the file and find out for

A0000001-0000001-1-4
A0000001-0000001-2-4
A0000001-0000001-3-4
A0000001-0000001-4-4

and remove it so that i will get the proper xml.

and in the same way as output from my batch i will get the same kind of xml string.

I need to find out the size and if it is > 30k, i need to split the xml string using (need to insert the below split string in between the xml string and send).
A0000001-0000001-1-4
A0000001-0000001-2-4
A0000001-0000001-3-4
A0000001-0000001-4-4


Below, is the sample xml string,

F0008243-0000001-1-5<AutoPolicy><PolicyNumber>F0008243-0000001-1-5</PolicyNumber><TransactionCode>52</TransactionCode><PolicyType> </PolicyType><Process>RENEWALS</Process><State>NJ
F0008243-0000001-2-5</State><Company>NJM</Company><RateIndicator>3</RateIndicator><PolicyEffectiveDate>02/25/2012</PolicyEffectiveDate><RateEffectiveDateRenewingFrom>3
F0008243-0000001-3-5</RateEffectiveDateRenewingFrom

Please tell me the best way to do it.

Basically while reading input file I need to remove the split string (F0008243-0000001-1-5) and stror in DB.

After processing i need to insert the split string into xml string and send.

Please suggesst me the best approach.

Thanks
0
Comment
Question by:RameshLathu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
ambience earned 500 total points
ID: 37724040
Hmm .. how about reading all in a string and then using a regular expression for the 20-byte string to split the input. This would work as long as the autonumber string is not supposed to occur inside XML.

OR to be more robust you could write a simple parser which reads a autonumber first and then it keeps reading XML till the ending tag and then switches the state and read a number again. This should be simple considering the XML has balanced < and > characters and once you encounter a starting < you read till and ending >.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question