Solved

Filestream C#

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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 …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now