Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading .dat files

Status
Not open for further replies.

daisypolly

Programmer
Apr 28, 2005
38
CA
Hi,

How can I read .dat files. And display it in the text box. Any help will be appreciated.

Thanks
Daisy
 
search these forums (and your help system and/or for "open" "read" "input"
and you will find plenty of samples.

Now display a file on a text box will only work "well" if the file is not a binary file. If it is you will probably get unwanted effects.

Once you have some code you can comeback to us to help you if you still have some problems.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks for the code. The code works but the file is encrypted so the data it reads is not correct could you please suggest another way.

Thanks a bunch
Daisy
 
if the file is encrypted then you need to remove that first using whatever encryption method used.

And as I said if it is a binary file there is no point in loading it into a text box. and an encrypted file IS BINARY.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks. Can you please tell me how can I tell if the file is binary. In my file the words look like this.

rashid Ö Ö 3 Ö Ö 8 Ö Ö Ö Ö Ö 0 Ö =!=

Does this mean this is binary.

Thanks
Daisy
 
Yes.
All files that have non-printable chars are normally considered binary.

This is really not going anywhere.

What is the file you are reading? who/what program created it, and what are you trying to do exactly with it.

If this file is create by an application that uses "packed" numbers, then you will never be able to load the file directly. You will first need to convert those numbers into a "edited" format, and then display them.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks, The file that I want to read is .dat file. The program that created was a visual basic program that some programmer coded. I know how the program works though The user enters some numbers in the program and those numbers go in this .dat file.What are packed numbers.
 
then contact the programmer and ask him/her for help.

Without knowing how the values are written to the file it is almost impossible to "decode" them. If encryption is used then it is almost impossible unless you find the encryption method and the key to decode it.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thank for the help.I will make guesses and try to decode it. Thanks again.

Daisy
 
Unless this is an illicit venture then the original supplier and/or programmer will have the algorithm and will save you much time and effort. If we could know a little more of the background it may help us.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
The other potential problem here is that ".dat" is not a "standard" extension that dictates some specific format. I have seen Excel files, Word Files, CSV files, dBF files and numerous proprietary files use the .dat extension. Your file may not be encrypted at all ... it may simply be in a format that you are not expecting.
 
I know a little about the file. I think it is a text file being encrypted.I will get more information and let you know what I find from that person.

Thanks a bunch guys.
Daisy
 
Well, it could also be the result of a .save method call from an ADO recordset, couldn't it? In which case, all you need to do is use the MsPersist provider to open the .dat file into a recordset.

Bob
 
Ok I found that this file is not encrypted at all so I think bob is correct could you please show me what i need to do to read it.

Thanks a bunch
 
Code:
dim cn as adodb.connection
dim rs as adodb.recordset
set cn = new adodb.connection
cn.open "Provider=MsPersist"
set rs = new adodb.recordset
rs.open "mypath\myfile", cn
'where mypath\myfile is a valid xml file

HTH

Bob
 
Given we can already see that the .dat file isn't an XML file, that probably won't work ...

Daisy, you really need to find out more from the original programmer as advised by anumber of people in this thread. Guessing really isn't going to get you anywhere quickly
 
Oh yeah, it's a dat file, I forgot. However, you can do the same with text files, can't you? I mean, if the .dat file is the result of a recordset save, and somebody didn't specify adPersistHTML, I do believe you open it the same way, don't you? Never tried it.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top