Hi,
In my app, I open a file using a FileStream then pass it to a
BinaryWriter. I then use the BinaryWriter instance to write to my file. But
a problem arose : The file never gets bigger than 1kb. The code calls the
bw.write(TheValue), but nothing is written after 1kb. I'm I missing
something?
Here's the way I create my FileStream and BinaryWriter :
Filename = System.Environment.CurrentDirectory() & "\msec.dat"
fs = System.IO.File.OpenWrite(Filename)
bw = New System.IO.BinaryWriter(fs)
When I write I do:
bw.write(TheValueToWrite)
And when done writing, I do :
bw.close
fs.close
Am I missing something?
Thanks
ThunderMusic 6 2912
What's "TheValueToWrite" defined as? Are you just writing one value?
Scott Swigart
VB - MVP
"ThunderMusic" wrote: Hi, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file. But a problem arose : The file never gets bigger than 1kb. The code calls the bw.write(TheValue), but nothing is written after 1kb. I'm I missing something?
Here's the way I create my FileStream and BinaryWriter :
Filename = System.Environment.CurrentDirectory() & "\msec.dat" fs = System.IO.File.OpenWrite(Filename) bw = New System.IO.BinaryWriter(fs)
When I write I do:
bw.write(TheValueToWrite)
And when done writing, I do :
bw.close fs.close
Am I missing something?
Thanks
ThunderMusic
hi,
no, I'm not writing just 1 value... the "TheValueToWrite" was just a name I
put there because it could be almost any base type : string, bit, byte,
int16, int32, int64, et al. I go through many steps and would have to write
from 2k to about 500k (I don't think it will go higher than that, but it
could).
For now, I write almost just strings, int32 and booleans but it could be
anything...
thanks
ThunderMusic
"Scott Swigart" <sc***@swigartconsulting.com> a écrit dans le message de
news:26**********************************@microsof t.com... What's "TheValueToWrite" defined as? Are you just writing one value?
Scott Swigart VB - MVP
"ThunderMusic" wrote:
Hi, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file.
But a problem arose : The file never gets bigger than 1kb. The code calls
the bw.write(TheValue), but nothing is written after 1kb. I'm I missing something?
Here's the way I create my FileStream and BinaryWriter :
Filename = System.Environment.CurrentDirectory() & "\msec.dat" fs = System.IO.File.OpenWrite(Filename) bw = New System.IO.BinaryWriter(fs)
When I write I do:
bw.write(TheValueToWrite)
And when done writing, I do :
bw.close fs.close
Am I missing something?
Thanks
ThunderMusic
There shouldn't be anything special beyond what you're doing. Here's a
console app that writes out about 4MB using the same technique.
Imports System.IO
Module Module1
Sub Main()
Dim data As String = "0123456789012345678901234567890123456789"
Dim filename As String = System.Environment.CurrentDirectory() &
"\msec.dat"
Dim fs As Stream = File.Open(filename, FileMode.Create,
FileAccess.Write)
Dim b As New BinaryWriter(fs)
For i As Integer = 1 To 100000
b.Write(data)
Next
b.Close()
fs.Close()
End Sub
End Module
"ThunderMusic" wrote: hi, no, I'm not writing just 1 value... the "TheValueToWrite" was just a name I put there because it could be almost any base type : string, bit, byte, int16, int32, int64, et al. I go through many steps and would have to write from 2k to about 500k (I don't think it will go higher than that, but it could).
For now, I write almost just strings, int32 and booleans but it could be anything...
thanks
ThunderMusic
"Scott Swigart" <sc***@swigartconsulting.com> a écrit dans le message de news:26**********************************@microsof t.com... What's "TheValueToWrite" defined as? Are you just writing one value?
Scott Swigart VB - MVP
"ThunderMusic" wrote:
Hi, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file. But a problem arose : The file never gets bigger than 1kb. The code calls the bw.write(TheValue), but nothing is written after 1kb. I'm I missing something?
Here's the way I create my FileStream and BinaryWriter :
Filename = System.Environment.CurrentDirectory() & "\msec.dat" fs = System.IO.File.OpenWrite(Filename) bw = New System.IO.BinaryWriter(fs)
When I write I do:
bw.write(TheValueToWrite)
And when done writing, I do :
bw.close fs.close
Am I missing something?
Thanks
ThunderMusic
thunderbyte, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file. But a problem arose : The file never gets bigger than 1kb. The code calls the bw.write(TheValue), but nothing is written after 1kb. I'm I missing something?
Strange, if I use your code to write 15Kb of bytes I get 15Kb
Cor
Is it possible that when you write TheValueToWrite to the file, you are
overwriting what is already in the file? Try opening the file stream
in Append mode so that subsequent writes are appended to the end of the
current file.
hi,
Finaly, I found my problem was because while the app was running the
application path was changing, so the file was not writing at the same place
anymore. So when I was looking back to the file that was written (before the
path change) it was 1k long (just a coincidence it was exactly this long),
but the other one (written later in the app process, after the path change)
was containing all the required data.
I replaced the application path with a constant path and now it works fine.
Sorry for bothering and thanks for all the help you provided
ThunderMusic
"ThunderMusic" <NO*******@sympatico.caSPAMATALL> a écrit dans le message de
news:eV**************@TK2MSFTNGP10.phx.gbl... Hi, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file.
But a problem arose : The file never gets bigger than 1kb. The code calls the bw.write(TheValue), but nothing is written after 1kb. I'm I missing something?
Here's the way I create my FileStream and BinaryWriter :
Filename = System.Environment.CurrentDirectory() & "\msec.dat" fs = System.IO.File.OpenWrite(Filename) bw = New System.IO.BinaryWriter(fs)
When I write I do:
bw.write(TheValueToWrite)
And when done writing, I do :
bw.close fs.close
Am I missing something?
Thanks
ThunderMusic
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michel Rosien |
last post by:
Hello All,
I am trying to read data from a textfile using std::ifstream.
The problem is that I have a very huge text file, approximately 4.8 GB.
When I use this file, the program I wrote refuses...
|
by: Mark Miller |
last post by:
I have a char array and when I write it to a file using BinaryWriter the
position of the pointer is the size of the array + 1. For example: writing
char leaves the pointer at position 26 after...
|
by: Ken |
last post by:
I would like to measure the fileSize of the image (without uploading it -
php).
I use:
var size_pic = document.getElementById('num1').childNodes.fileSize;
alert("size = " + size_pic);
which...
|
by: Filip Strugar |
last post by:
Considering that the BinaryWriter/BinaryReader object closes the underlaying
stream upon being gc collected, is the following code correct, and if it is
what is the reason preventing BinaryWriter...
|
by: Eugene |
last post by:
I'm trying to write a class which uses BinaryWriter as its base but allows
for queuing of write requests
Public Class QueuedBinaryWriter
Inherits BinaryWriter
I override all the Write methods...
|
by: Thomas Gurath |
last post by:
I have some code that reads a file from disk and inserts it into the
http response. When the user clicks the file's title linkbutton, the
File Download prompt appears twice if they select Open...
|
by: ThunderMusic |
last post by:
Hi,
In my app, I open a file using a FileStream then pass it to a
BinaryWriter. I then use the BinaryWriter instance to write to my file. But
a problem arose : The file never gets bigger than 1kb....
|
by: VB Programmer |
last post by:
I am using a FileUpload control (ASP.NET 2.0). How do I check the length of
the file in bytes BEFORE I let them upload it?
I believe my code checks now AFTER...
If...
|
by: =?Utf-8?B?ZnVuZG9vX2ty?= |
last post by:
Check the following code
///Buffer to store the data
byte data = new byte;
///Create a memory stream from the buffer
MemoryStream memStream = new MemoryStream(data);
///Binary writer...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |