Menu
Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
VB.NET General Discussion
Write int16 array(2,500,000) to binary file
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="dbAny" data-source="post: 7293" data-attributes="member: 2760"><p>I am trying to convert a vb6 app to a vb.net app.</p><p></p><p>I am having a problem with writing 2,500,000 16 bit values from an array to a file. In vb6 I used the </p><p></p><p>API instruction:</p><p></p><p> WriteFile lApiDataFile, binData(0), lSize, lApiReturn, ByVal 0&</p><p></p><p>However I cannot get this instruction to compile in vb.net I then tried to use: </p><p></p><p> Dim swFile As StreamWriter = File.CreateText("C:\myfile.ext")</p><p> dim binData(5000000) as binary</p><p></p><p> swFile.Write(data, 0, 5000000)</p><p> swFile.Flush()</p><p> swFile.Close()</p><p></p><p>This works fine with a binary data array. However I cannot figure out how to do this with a integer array </p><p> dim binData(2500000) as int16</p><p></p><p>When I do this I need to use a loop</p><p> For ii = 0 To 2500000</p><p> swFile.Write(binData(ii))</p><p> Next</p><p>which takes too long.</p><p></p><p>I am doing a "real time" application, and need to store ~ 10 Mbytes of data every 5 seconds. Thus I need to use the API or a flush instruction to ensure that the file write is completed before I can continue.</p><p></p><p>Can anyone suggest a way to: </p><p> how to use the API writefile in vb.net</p><p> How to "address" the int16 array with a byte array so that I can use .write without a loop</p></blockquote><p></p>
[QUOTE="dbAny, post: 7293, member: 2760"] I am trying to convert a vb6 app to a vb.net app. I am having a problem with writing 2,500,000 16 bit values from an array to a file. In vb6 I used the API instruction: WriteFile lApiDataFile, binData(0), lSize, lApiReturn, ByVal 0& However I cannot get this instruction to compile in vb.net I then tried to use: Dim swFile As StreamWriter = File.CreateText("C:\myfile.ext") dim binData(5000000) as binary swFile.Write(data, 0, 5000000) swFile.Flush() swFile.Close() This works fine with a binary data array. However I cannot figure out how to do this with a integer array dim binData(2500000) as int16 When I do this I need to use a loop For ii = 0 To 2500000 swFile.Write(binData(ii)) Next which takes too long. I am doing a "real time" application, and need to store ~ 10 Mbytes of data every 5 seconds. Thus I need to use the API or a flush instruction to ensure that the file write is completed before I can continue. Can anyone suggest a way to: how to use the API writefile in vb.net How to "address" the int16 array with a byte array so that I can use .write without a loop [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
VB.NET General Discussion
Write int16 array(2,500,000) to binary file
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom