I am writing a quick program to edit a binary file that contains file paths
(amongst other things). If I look at the files in notepad, they look like:
<gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish>
etc.
I want to remove the "g:\" from the file paths. I wrote a console app that
successfully reads the file and writes a duplicate of it, but fails for some
reason to do the "replacing" of the "g:\". The code follows with a note
showing the line that is not working. When I look at the "s" variable in
break mode, I see that VB does not show the entire file contents, even
though when I write "s" to the second file stream, the entire original file
is duplicated. I suppose this is because the file content isn't intended to
be interpreted as a string (its binary after all). It is probably hitting
some unfriendly bytes that it can't interpret for string operations like
Replace. If that's the case, maybe I need to interact with it a character at
a time, although I'm not sure how I would do a replace that way. Any ideas
or code would be greatly appreciated. As you can tell, I don't do much
binary file I/O.
Sub Main()
'read the binary file into a string var
Dim fs As New FileStream("C:\ Source\Sample and
Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read )
Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8)
Dim s As String = sr.ReadToEnd
sr.Close()
fs.Close()
'remove the hard-coded drive letter specification
s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes
Dim fs2 As New FileStream("C:\ Source\Sample and
Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New, FileAccess.Writ e)
Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8)
sw.Write(s)
sw.Close()
fs2.Close()
End Sub 12 5858
Hi Adam,
A simple one because you are not the first one who did that as you do .
s = s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
or
dim b as String = s.Replace...... .
Before you ask why
:-)
I hope this helps?
Cor
* "Adam J. Schaff" <ab****@adelphi a.net> scripsit: 'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'Replace' is a "function", so it returns the result:
\\\
s = s.Replace(...)
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
From the mountains in Austria are comming more and more echo's. 'Replace' is a "function", so it returns the result:
\\\ s = s.Replace(...) ///
Adam,
If you are editing a binary file I would recommend opening the file with a
BinaryReader or even just FileStream directly. Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8)
If you use a StreamReader, you are actually converting the file into Text
(8bit bytes to 16 bit chars) then converting the file back into Binary.
My two concerns with using a StreamReader are:
1. depending on what the binary file actually contains (an exe for example)
removing or adding characters may actually corrupt the file, as the file
contains length & offset fields...
2. Loosing certain bytes, ones that are not translated nicely from arbitrary
bytes back & forth to Unicode. For example using Encoding.ASCII will trash
your file as ASCII is 7 bit, you will loose all the high order bits. I
suspect with UTF8 you will be OK, however it just does not feel right...
Here is a simple program that will copy a file one byte at a time, the trick
is going to be modify it so it looks for "g:\" one byte at a time and skips
those bytes, only if all three are found... Especially if you want to ensure
they are prefaced with "file//".
Dim input As New FileStream("Onl y Fools.fpl", FileMode.Open)
Dim output As New FileStream("Onl y Fools2.fpl", FileMode.Create )
Dim value As Integer
value = input.ReadByte( )
Do Until value = -1
output.WriteByt e(CByte(value))
value = input.ReadByte( )
Loop
input.Close()
output.Close()
Hope this helps
Jay
"Adam J. Schaff" <ab****@adelphi a.net> wrote in message
news:Ok******** ******@TK2MSFTN GP11.phx.gbl... I am writing a quick program to edit a binary file that contains file
paths (amongst other things). If I look at the files in notepad, they look like:
<gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish> etc.
I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails for
some reason to do the "replacing" of the "g:\". The code follows with a note showing the line that is not working. When I look at the "s" variable in break mode, I see that VB does not show the entire file contents, even though when I write "s" to the second file stream, the entire original
file is duplicated. I suppose this is because the file content isn't intended
to be interpreted as a string (its binary after all). It is probably hitting some unfriendly bytes that it can't interpret for string operations like Replace. If that's the case, maybe I need to interact with it a character
at a time, although I'm not sure how I would do a replace that way. Any ideas or code would be greatly appreciated. As you can tell, I don't do much binary file I/O.
Sub Main() 'read the binary file into a string var Dim fs As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read ) Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) Dim s As String = sr.ReadToEnd sr.Close() fs.Close()
'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes Dim fs2 As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New,
FileAccess.Writ e) Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8) sw.Write(s)
sw.Close() fs2.Close() End Sub
Doh! I was so absorbed with the dangers of dealing with binary data as text,
that I forgot to check for obvoius blunders. I've used Replace before and
should have known better! Thanks for not adding "what a flaming idiot" to
your replies. ;-)
"Adam J. Schaff" <ab****@adelphi a.net> wrote in message
news:Ok******** ******@TK2MSFTN GP11.phx.gbl... I am writing a quick program to edit a binary file that contains file
paths (amongst other things). If I look at the files in notepad, they look like:
<gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish> etc.
I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails for
some reason to do the "replacing" of the "g:\". The code follows with a note showing the line that is not working. When I look at the "s" variable in break mode, I see that VB does not show the entire file contents, even though when I write "s" to the second file stream, the entire original
file is duplicated. I suppose this is because the file content isn't intended
to be interpreted as a string (its binary after all). It is probably hitting some unfriendly bytes that it can't interpret for string operations like Replace. If that's the case, maybe I need to interact with it a character
at a time, although I'm not sure how I would do a replace that way. Any ideas or code would be greatly appreciated. As you can tell, I don't do much binary file I/O.
Sub Main() 'read the binary file into a string var Dim fs As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read ) Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) Dim s As String = sr.ReadToEnd sr.Close() fs.Close()
'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes Dim fs2 As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New,
FileAccess.Writ e) Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8) sw.Write(s)
sw.Close() fs2.Close() End Sub
Jay,
Thanks for the code. I looked at using the binary reader, but couldn't
figure out how to tell when it reaches EOF. Had no idea about the -1 trick.
That said, I'm still not sure what the code would look like to test one byte
at a time for a sequence of 6 characters, particularly if those characters
are stored as 2 bytes each. Hmm, I suppose there is a ReadChar method, but
if I use that instead, I couldn't use the -1 trick. Also, how would I write
it back to the output file if I use ReadChar instead of ReadByte? Is there a
WriteChar, and will it cause problems if some of the data I'm reading with
ReadChar isn't really a char? Ack! I'm just too new to all this. I don't
even understand the use of cbyte in your code (isn't it a byte already?).
Well, at least I have food for thought. Thanks again for the advice. I can
see I have a lot to learn.
Even if I do stay with the stream reader, I'll take your worries to heart
and will add code to backup the file before I play with it. That's just good
common sense.
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:uA******** ******@TK2MSFTN GP12.phx.gbl... Adam, If you are editing a binary file I would recommend opening the file with a BinaryReader or even just FileStream directly.
Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) If you use a StreamReader, you are actually converting the file into Text (8bit bytes to 16 bit chars) then converting the file back into Binary.
My two concerns with using a StreamReader are: 1. depending on what the binary file actually contains (an exe for
example) removing or adding characters may actually corrupt the file, as the file contains length & offset fields... 2. Loosing certain bytes, ones that are not translated nicely from
arbitrary bytes back & forth to Unicode. For example using Encoding.ASCII will trash your file as ASCII is 7 bit, you will loose all the high order bits. I suspect with UTF8 you will be OK, however it just does not feel right...
Here is a simple program that will copy a file one byte at a time, the
trick is going to be modify it so it looks for "g:\" one byte at a time and
skips those bytes, only if all three are found... Especially if you want to
ensure they are prefaced with "file//".
Dim input As New FileStream("Onl y Fools.fpl", FileMode.Open) Dim output As New FileStream("Onl y Fools2.fpl", FileMode.Create ) Dim value As Integer value = input.ReadByte( ) Do Until value = -1 output.WriteByt e(CByte(value)) value = input.ReadByte( ) Loop input.Close() output.Close()
Hope this helps Jay
"Adam J. Schaff" <ab****@adelphi a.net> wrote in message news:Ok******** ******@TK2MSFTN GP11.phx.gbl... I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look
like:
<gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish> etc.
I want to remove the "g:\" from the file paths. I wrote a console app
that successfully reads the file and writes a duplicate of it, but fails for some reason to do the "replacing" of the "g:\". The code follows with a note showing the line that is not working. When I look at the "s" variable in break mode, I see that VB does not show the entire file contents, even though when I write "s" to the second file stream, the entire original file is duplicated. I suppose this is because the file content isn't intended to be interpreted as a string (its binary after all). It is probably
hitting some unfriendly bytes that it can't interpret for string operations like Replace. If that's the case, maybe I need to interact with it a
character at a time, although I'm not sure how I would do a replace that way. Any
ideas or code would be greatly appreciated. As you can tell, I don't do much binary file I/O.
Sub Main() 'read the binary file into a string var Dim fs As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read ) Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) Dim s As String = sr.ReadToEnd sr.Close() fs.Close()
'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes Dim fs2 As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New, FileAccess.Writ e) Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8) sw.Write(s)
sw.Close() fs2.Close() End Sub
p.s. I just notice that value is an integer. That explains the cbyte in your
code, but now I'm confused why ReadByte returns an integer?? Is it something
to do with testing for EOF? (-1 isn't a typical byte value it occurs to me
;)
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:uA******** ******@TK2MSFTN GP12.phx.gbl... Adam, If you are editing a binary file I would recommend opening the file with a BinaryReader or even just FileStream directly.
Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) If you use a StreamReader, you are actually converting the file into Text (8bit bytes to 16 bit chars) then converting the file back into Binary.
My two concerns with using a StreamReader are: 1. depending on what the binary file actually contains (an exe for
example) removing or adding characters may actually corrupt the file, as the file contains length & offset fields... 2. Loosing certain bytes, ones that are not translated nicely from
arbitrary bytes back & forth to Unicode. For example using Encoding.ASCII will trash your file as ASCII is 7 bit, you will loose all the high order bits. I suspect with UTF8 you will be OK, however it just does not feel right...
Here is a simple program that will copy a file one byte at a time, the
trick is going to be modify it so it looks for "g:\" one byte at a time and
skips those bytes, only if all three are found... Especially if you want to
ensure they are prefaced with "file//".
Dim input As New FileStream("Onl y Fools.fpl", FileMode.Open) Dim output As New FileStream("Onl y Fools2.fpl", FileMode.Create ) Dim value As Integer value = input.ReadByte( ) Do Until value = -1 output.WriteByt e(CByte(value)) value = input.ReadByte( ) Loop input.Close() output.Close()
Hope this helps Jay
"Adam J. Schaff" <ab****@adelphi a.net> wrote in message news:Ok******** ******@TK2MSFTN GP11.phx.gbl... I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look
like:
<gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish> etc.
I want to remove the "g:\" from the file paths. I wrote a console app
that successfully reads the file and writes a duplicate of it, but fails for some reason to do the "replacing" of the "g:\". The code follows with a note showing the line that is not working. When I look at the "s" variable in break mode, I see that VB does not show the entire file contents, even though when I write "s" to the second file stream, the entire original file is duplicated. I suppose this is because the file content isn't intended to be interpreted as a string (its binary after all). It is probably
hitting some unfriendly bytes that it can't interpret for string operations like Replace. If that's the case, maybe I need to interact with it a
character at a time, although I'm not sure how I would do a replace that way. Any
ideas or code would be greatly appreciated. As you can tell, I don't do much binary file I/O.
Sub Main() 'read the binary file into a string var Dim fs As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read ) Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) Dim s As String = sr.ReadToEnd sr.Close() fs.Close()
'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes Dim fs2 As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New, FileAccess.Writ e) Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8) sw.Write(s)
sw.Close() fs2.Close() End Sub
Adam,
&hFF (-1) is a valid Byte value, returning an integer allows -1 for EOF &
&HFF for the byte.
Hope this helps
Jay
"Adam J. Schaff" <as*****@cascoc dev.com> wrote in message
news:OU******** ******@tk2msftn gp13.phx.gbl... p.s. I just notice that value is an integer. That explains the cbyte in
your code, but now I'm confused why ReadByte returns an integer?? Is it
something to do with testing for EOF? (-1 isn't a typical byte value it occurs to me ;)
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message news:uA******** ******@TK2MSFTN GP12.phx.gbl... Adam, If you are editing a binary file I would recommend opening the file with
a BinaryReader or even just FileStream directly.
Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8)
If you use a StreamReader, you are actually converting the file into
Text (8bit bytes to 16 bit chars) then converting the file back into Binary.
My two concerns with using a StreamReader are: 1. depending on what the binary file actually contains (an exe for example) removing or adding characters may actually corrupt the file, as the file contains length & offset fields... 2. Loosing certain bytes, ones that are not translated nicely from arbitrary bytes back & forth to Unicode. For example using Encoding.ASCII will
trash your file as ASCII is 7 bit, you will loose all the high order bits. I suspect with UTF8 you will be OK, however it just does not feel right...
Here is a simple program that will copy a file one byte at a time, the trick is going to be modify it so it looks for "g:\" one byte at a time and skips those bytes, only if all three are found... Especially if you want to ensure they are prefaced with "file//".
Dim input As New FileStream("Onl y Fools.fpl", FileMode.Open) Dim output As New FileStream("Onl y Fools2.fpl", FileMode.Create ) Dim value As Integer value = input.ReadByte( ) Do Until value = -1 output.WriteByt e(CByte(value)) value = input.ReadByte( ) Loop input.Close() output.Close()
Hope this helps Jay
"Adam J. Schaff" <ab****@adelphi a.net> wrote in message news:Ok******** ******@TK2MSFTN GP11.phx.gbl... I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: <gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish> etc.
I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails
for some reason to do the "replacing" of the "g:\". The code follows with a
note showing the line that is not working. When I look at the "s" variable
in break mode, I see that VB does not show the entire file contents, even though when I write "s" to the second file stream, the entire original file is duplicated. I suppose this is because the file content isn't
intended to be interpreted as a string (its binary after all). It is probably hitting some unfriendly bytes that it can't interpret for string operations
like Replace. If that's the case, maybe I need to interact with it a character at a time, although I'm not sure how I would do a replace that way. Any ideas or code would be greatly appreciated. As you can tell, I don't do much binary file I/O.
Sub Main() 'read the binary file into a string var Dim fs As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read ) Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) Dim s As String = sr.ReadToEnd sr.Close() fs.Close()
'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes Dim fs2 As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New,
FileAccess.Writ e) Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8) sw.Write(s)
sw.Close() fs2.Close() End Sub
Adam,
For a binary file, it really depends on the encoding, which I would try to
avoid! If you were using UTF8 and it worked then there is 1 char per byte.
If you need UTF16, then you have (16bit) Unicode itself & there are 2 bytes
per char (in the file), there is also a UTF32 ;-). In other words do not
confuse how a string is represented in memory and how text is encoded in a
file. Binary files could actually have multiple encodings of text. Consider
a file that stores the code page & the length of a string, followed by the
code page encoded value of the string... Speaking of which if you binary
file stores the length of the string, removing the "g:\" may cause problems
;-)
If you start using ReadChar & WriteChar you are back to translating to Text.
Assuming your file is not EBCDIC & you are not using any extended character
(an umlated a for example "ä"). A single byte in your file will contain a
single character. EBCDIC you still have 1 byte per single character however
its bit representation are different, extended characters (ANSI code pages)
are single character per byte, but bytes 128 to 255 have different bit
representations ...
You can then use Asc or AscW to convert a char into a integer/byte. value = input.ReadByte( ) Do Until value = -1
if value = AscW("G"c)
' found a G, look for a :
End if output.WriteByt e(CByte(value)) value = input.ReadByte( ) Loop
For information on Unicode and other character sets see: http://www.yoda.arachsys.com/csharp/unicode.html
A couple other articles that may help: http://www.yoda.arachsys.com/csharp/...ngunicode.html
Hope this helps
Jay
"Adam J. Schaff" <as*****@cascoc dev.com> wrote in message
news:ev******** ******@TK2MSFTN GP12.phx.gbl... Jay,
Thanks for the code. I looked at using the binary reader, but couldn't figure out how to tell when it reaches EOF. Had no idea about the -1
trick. That said, I'm still not sure what the code would look like to test one
byte at a time for a sequence of 6 characters, particularly if those characters are stored as 2 bytes each. Hmm, I suppose there is a ReadChar method, but if I use that instead, I couldn't use the -1 trick. Also, how would I
write it back to the output file if I use ReadChar instead of ReadByte? Is there
a WriteChar, and will it cause problems if some of the data I'm reading with ReadChar isn't really a char? Ack! I'm just too new to all this. I don't even understand the use of cbyte in your code (isn't it a byte already?). Well, at least I have food for thought. Thanks again for the advice. I can see I have a lot to learn.
Even if I do stay with the stream reader, I'll take your worries to heart and will add code to backup the file before I play with it. That's just
good common sense.
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message news:uA******** ******@TK2MSFTN GP12.phx.gbl... Adam, If you are editing a binary file I would recommend opening the file with
a BinaryReader or even just FileStream directly.
Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8)
If you use a StreamReader, you are actually converting the file into
Text (8bit bytes to 16 bit chars) then converting the file back into Binary.
My two concerns with using a StreamReader are: 1. depending on what the binary file actually contains (an exe for example) removing or adding characters may actually corrupt the file, as the file contains length & offset fields... 2. Loosing certain bytes, ones that are not translated nicely from arbitrary bytes back & forth to Unicode. For example using Encoding.ASCII will
trash your file as ASCII is 7 bit, you will loose all the high order bits. I suspect with UTF8 you will be OK, however it just does not feel right...
Here is a simple program that will copy a file one byte at a time, the trick is going to be modify it so it looks for "g:\" one byte at a time and skips those bytes, only if all three are found... Especially if you want to ensure they are prefaced with "file//".
Dim input As New FileStream("Onl y Fools.fpl", FileMode.Open) Dim output As New FileStream("Onl y Fools2.fpl", FileMode.Create ) Dim value As Integer value = input.ReadByte( ) Do Until value = -1 output.WriteByt e(CByte(value)) value = input.ReadByte( ) Loop input.Close() output.Close()
Hope this helps Jay
"Adam J. Schaff" <ab****@adelphi a.net> wrote in message news:Ok******** ******@TK2MSFTN GP11.phx.gbl... I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: <gibberish>fi le//g:\pathtofile1< gibberish>file//g:\pathtofile2< gibberish> etc.
I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails
for some reason to do the "replacing" of the "g:\". The code follows with a
note showing the line that is not working. When I look at the "s" variable
in break mode, I see that VB does not show the entire file contents, even though when I write "s" to the second file stream, the entire original file is duplicated. I suppose this is because the file content isn't
intended to be interpreted as a string (its binary after all). It is probably hitting some unfriendly bytes that it can't interpret for string operations
like Replace. If that's the case, maybe I need to interact with it a character at a time, although I'm not sure how I would do a replace that way. Any ideas or code would be greatly appreciated. As you can tell, I don't do much binary file I/O.
Sub Main() 'read the binary file into a string var Dim fs As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools.fpl", FileMode.Open, FileAccess.Read ) Dim sr As New StreamReader(fs , System.Text.Enc oding.UTF8) Dim s As String = sr.ReadToEnd sr.Close() fs.Close()
'remove the hard-coded drive letter specification s.Replace("file ://G:\", "file://") 'THIS LINE DOES NOT WORK
'write a new binary file with my changes Dim fs2 As New FileStream("C:\ Source\Sample and Demo\Foobar\Edi tFpl\Only Fools2.fpl", FileMode.Create New,
FileAccess.Writ e) Dim sw As New StreamWriter(fs 2, System.Text.Enc oding.UTF8) sw.Write(s)
sw.Close() fs2.Close() End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: yaipa |
last post by:
What would be the common sense way of finding a binary pattern in a
..bin file, say some 200 bytes, and replacing it with an updated pattern
of the same length at the same offset?
Also, the pattern can occur on any byte boundary in the file, so
chunking through the code at 16 bytes a frame maybe a problem. The
file itself isn't so large,...
|
by: Eric |
last post by:
Assume that disk space is not an issue
(the files will be small < 5k in general for the purpose of storing
preferences)
Assume that transportation to another OS may never occur.
Are there any solid reasons to prefer text files over binary files
files?
|
by: Yeow |
last post by:
hello,
i was trying to use the fread function on SunOS and ran into some
trouble.
i made a simple test as follows:
i'm trying to read in a binary file (generated from a fortran code)
that contains the following three floating-point numbers:
1.0 2.0 3.0
|
by: Michael Mair |
last post by:
Cheerio,
I would appreciate opinions on the following:
Given the task to read a _complete_ text file into a string:
What is the "best" way to do it?
Handling the buffer is not the problem -- the character
input is a different matter, at least if I want to remain within
the bounds of the standard library.
|
by: Wei Su |
last post by:
Hi,
I have a text file abc.txt and it looks like:
12 34 56
23 45 56
33 56 78
... .. ..
... .. ..
I want to get how many rows totally in the text file, how to do this?
Thanks.
| |
by: Ryan Liu |
last post by:
Hi,
I want to backup database to a text file. There are binary columns.
I read byte from the column and use ASCII encoding convert it to string
and write to a text file.
But there are bytes large than 7F, and I lost 80Hex, e.g. 91Hex will be
11Hex.
|
by: Josh Baltzell |
last post by:
I am having a lot more trouble with this than I thought I would. Here
is what I want to do in pseudocode.
Open c:\some.pdf
Replace "Replace this" with "Replaced!"
Save c:\some_edited.pdf
I can do this in notepad and it works fine, but when I start getting in
to reading the files I think it has some encoding problem. I tried
saving the...
|
by: Lauren Quantrell |
last post by:
I have an HTML file named myHTML.htm
It looks like this:
<great HTML code>
<more great HTML code>
<even more great HTML code>
<insert HTML here>
|
by: dm3281 |
last post by:
Hello, I have a text report from a mainframe that I need to parse.
The report has about a 2580 byte header that contains binary information
(garbage for the most part); although there are a couple areas that have
ASCII text that I need to extract. At the end of the 2580 bytes, I can read
the report like a standard text file. It should have...
|
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. ...
|
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...
| |
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |