I am getting an extra character at te beginning of the file,
can someone please check if there is an error in my code?
Dim fs As FileStream
fs = New FileStream(Form 1.REGFILE, FileMode.Create New, FileAccess.Writ e)
Dim gw As New BinaryWriter(fs )
gw.Write(s)
gw.Flush()
gw.Close()
fs.Close() 4 1112
"dinny" <nospam> schrieb: I am getting an extra character at te beginning of the file, can someone please check if there is an error in my code?
Dim fs As FileStream fs = New FileStream(Form 1.REGFILE, FileMode.Create New, FileAccess.Writ e) Dim gw As New BinaryWriter(fs ) gw.Write(s) gw.Flush() gw.Close() fs.Close()
Maybe the character is an UTF BOM:
<URL:http://www.unicode.org/faq/utf_bom.html>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Dinny,
Review the help for BinaryWriter.Wr ite(String)!
Seeing as BinaryWriter is writing a Binary File, it encodes the length of
the string before it writes the encoded characters of the string. It does
this so as to allow reading back the same number of characters in
BinaryReader.Re adString.
For information on the encoded length see the following:
BinaryWriter.Wr ite(String): http://msdn.microsoft.com/library/de...iteTopic13.asp
Corresponding BinaryReader.Re adString: http://msdn.microsoft.com/library/de...tringTopic.asp
Hope this helps
Jay
"dinny" <nospam> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. I am getting an extra character at te beginning of the file, can someone please check if there is an error in my code?
Dim fs As FileStream fs = New FileStream(Form 1.REGFILE, FileMode.Create New, FileAccess.Writ e) Dim gw As New BinaryWriter(fs ) gw.Write(s) gw.Flush() gw.Close() fs.Close()
For process text. Suggest use StreamWriter to replace BinaryWriter. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: marslee |
last post by:
How to write data in a file to the next line
fwrite($ourFileHandle , $_POST);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST);
I want the following output
Peter
Main.st
|
by: Mark Anderson |
last post by:
I have code to develop result page links (like a search engine) for some
results being passed from a database where I've no server-sdide acces -
thus JS.
The code is below and works fine except the function in the onClick
event of the link being written on screen fails indicating 'theForm' as
being passed through is 'not defined'. The form is being passed as
"document.resultAdd" and can be checked as arriving in my function.
So what...
|
by: Von Shean |
last post by:
I use the following code to format the numbers to have commas. But in case
when input is zero it returns an empty string....any ideas?
String.Format("{0:#,###.##}",dblNum);
|
by: Mullin Yu |
last post by:
i want to build an application of both gui and batch interface by using
windows application project.
i check either passing any args or not. if no, then open the gui
application. if yes, use the batch interface.
my problem is that i can output the string to the dos prompt when running
the exe file at dos prompt:
c:\>test.exe /?
|
by: roopeman |
last post by:
i need your help, my code as below :
//-----------------------------------------------------------------------
//Wrote by Michael April 30 2005
//-----------------------------------------------------------------------
using System.Text;
using System.Diagnostics;
using System.Threading;
| |
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if ((someString.IndexOf("something1",0) >= 0) ||
((someString.IndexOf("something2",0) >= 0) ||
|
by: MJK |
last post by:
Suppose I have the following function in my program:
void ExtractData(Ind *AM)
{
int i,j;
char str;
char c;
FILE *ext=fopen("test.out","r");
//suppose I have N line each with M digits (in here M=5) like: 1 2 2
|
by: samifiaz |
last post by:
I have to writen application in C# that can read or write data from a serial port.
Can you please send any code that can help me for that. Or even material that can help me understanding this.
Kindly do guide me through any tutorial,help book or even sugestion to initiate this project.
Your kind guidence means alot to me .
|
by: ravimishra11 |
last post by:
Hi friends,
I have written code in asp.net to read or write string in com port(COM1).But when i run the program i am not getting any output .Below is my code .How can i check the string which i have send in com port is available in com port for read.
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
port.Open();
// port.Write("He");
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |