Solved

Filestream C#

Posted on 2012-03-14
1
313 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
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

832 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