read binary file with fopen, already performed tests and does not work follow binary file
read binary file with fopen
Moderator: Rathinagiri
Re: read binary file with fopen
jairpinho
This file can be read without any problem:
This file can be read without any problem:
Code: Select all
#include "Fileio.ch"
#include "hmg.ch"
FUNCTION Main()
LOCAL cFile := "20161228.dtl"
LOCAL nHandle := fOpen(cFile, FO_READ + FO_COMPAT)
LOCAL nLen
LOCAL cContent
IF nHandle < 0
MsgBox("Error opening file!")
ELSE
fSeek(nHandle, 0, FS_SET)
nLen := HB_fSize(cFile)
//read all content of file
cContent := HB_fReadLen(nHandle, nLen)
MsgBox(Len(cContent))
//read 20 last bytes
fSeek(nHandle, -20, FS_END)
cContent := HB_fReadLen(nHandle, nLen)
MsgBox(Len(cContent))
fClose(nHandle)
ENDIF
RETURN NIL
Re: read binary file with fopen
KDJ wrote: ↑Sun Sep 10, 2017 12:22 pm jairpinho
This file can be read without any problem:Code: Select all
#include "Fileio.ch" #include "hmg.ch" FUNCTION Main() LOCAL cFile := "20161228.dtl" LOCAL nHandle := fOpen(cFile, FO_READ + FO_COMPAT) LOCAL nLen LOCAL cContent IF nHandle < 0 MsgBox("Error opening file!") ELSE fSeek(nHandle, 0, FS_SET) nLen := HB_fSize(cFile) //read all content of file cContent := HB_fReadLen(nHandle, nLen) MsgBox(Len(cContent)) //read 20 last bytes fSeek(nHandle, -20, FS_END) cContent := HB_fReadLen(nHandle, nLen) MsgBox(Len(cContent)) fClose(nHandle) ENDIF RETURN NIL
Hello KDJ you are reading the file size this is not an error, it will only give an error when trying to read the contents of the file that would be what I need to follow, an example of what is inside the file, I need to import this into a grid
- serge_girard
- Posts: 3178
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: read binary file with fopen
Jair,
IMO: better take a EDITBOX to display content.
For a GRID you will need to create several lines (say 80char), divide cContent in chuncks of 80chars and put them in a GRID.
Serge
IMO: better take a EDITBOX to display content.
For a GRID you will need to create several lines (say 80char), divide cContent in chuncks of 80chars and put them in a GRID.
Serge
There's nothing you can do that can't be done...
Re: read binary file with fopen
Serge,
This is a .DTL file.
I'm afraid that with EDITBOX you will not get anything, neither with FREADSTR() or similar low-level functions.
It would be necessary a tool that would make the contents of the file something readable.
This is a .DTL file.
I'm afraid that with EDITBOX you will not get anything, neither with FREADSTR() or similar low-level functions.
It would be necessary a tool that would make the contents of the file something readable.
I get by with a little help from my friends
- serge_girard
- Posts: 3178
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: read binary file with fopen
Absolutely right !
Browsing works with Free Hex Editor Neo.
Browsing works with Free Hex Editor Neo.
There's nothing you can do that can't be done...
Re: read binary file with fopen
Hello, I found the dtl files are data files, I'm trying to connect via odbs but without success, so I found the lib site need help to convert the mak file
http://dtemplatelib.sourceforge.net/index.htm
http://dtemplatelib.sourceforge.net/index.htm