Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimizing research on file type
Message
From
17/11/2016 11:26:45
 
 
To
17/11/2016 08:50:16
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01629800
Message ID:
01643620
Views:
29
>I have adjusted the top portion of the class to use the FileStream. Basically, I only need to top 2048 characters. So, once I have that, I simply put that into lcString and the rest of the code is simply as it has always been.
>
>
>Try
>
>   ' Get it into a stream
>   loFile = New FileStream(lcFile, FileMode.Open, FileAccess.Read, FileShare.Read)
>
>   ' If we can work with the file
>   If loFile.CanSeek Then
>
>      ' Initialization
>      lnLength = loFile.Length
>
>      ' Number of bytes to read
>      lnByteToRead = 2048
>
>      ' Maximum number of bytes to read
>      If lnLength < 2048 Then
>         lnByteToRead = lnLength
>      End If
>
>      ' Get the byte-order mark, if there is one
>      loByte = New Byte(lnByteToRead) {}
>
>      loFile.Read(loByte, 0, lnByteToRead - 1)
>   Else
>      cMessage = cUnableToReadTheFile
>      Clear()
>      Return False
>   End If
>
>   ' Close the file
>   loFile.Close()
>
>Catch loError As Exception
>End Try
>
>' Initialization
>lcString = Encoding.Default.GetString(loByte)
>
You should really refactor the above to implement IDisposable on FileStream.

>So, that part is faster. However, I found out the biggest latency, on a specific ZIP file contains 31,000 files is when I do the unzip by using the WinZip Command Prompt utility. I will have to look at that.

Look at the System.IO.Compression library. You can open a zip file, get a list of all entries and, from that, get the stream for each entry. See example here:
https://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive.entries(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
but for each entry call the Open() method instead which will return a stream
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform