Hi Guys, My PC developed an issue, as a result a large collection of files merged into single files?
I have decided to create a VB.net application that will scan a set path and process each file it finds e.g.
Sub Process_File(Byval sFileName as string)
Using SR as New StreamReader(sFileName)
Dim sData() as String = SR.ReadToEnd()
SR.Close
SR.Finalise()
SR.Dispose()
Dim sPattern as string = "wwww"+chr(x)+chr(y)+chr(z) '*** <- This is the specific search pattern : w = 4 char string, x, y & z = byte value
Dim uCNT as uInt16 = 0
Dim uLen as uint16 = 0
Dim matches as MatchCollection = Regex.Matches(sData, sPattern)
For each match as Match in matches
TextOutput(String.Format("{0} : {1} : {2}", match.Index, match.Length, match.Value) + vbcrlf)
Dim sOutFile as string = String.Format("{0} Split {1}{2}",IO.Path.GetFileNameWithoutExtension(sFileName), uCNT, IO.Path.GetExtension(sFileName)
If uCNT < Matches.count - 1
uLen = Matches(uCNT+1).Index - Matches(uCNT).Index
Else
uLen = sDATA.Length - Matches(uCNT).Index
EndIf
using SW as new StreamWriter(sOutFile)
SW.Write(strings.mid(sData, Matches(uCNT).Index, uLen))
SW.Close
SW.Finalise()
SW.Dispose()
end using
uCNT += 1
Next
End Using
End Sub
*note example may have typos? and not be complete? I'm using the sites html editor :-/
Everything appears to be working, the recursion supplies all the required files, the regex detects all the required headers, however the returned index doesn't appear to be returning the correct position (its about 3000 bytes short per item, i.e. item 2 would be 6000 bytes out?), the output files generated obviously don't work as their headers don't exist at the beginning of the files.
The help/documentation for regex isn't any use :-\ or no longer supported ???
Any Solution Ideas would be most appreciated and to all you guys wondering why would I want to do this I ask why don't you just supply a solution :-?
*Note the merged files are binary or contain a load of binary data so escape characters every where, I just want to unmerge the merged files! :-)
Thanks Guys