473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Finding the HEX value of a file

Hi all,

I need to find out the hex value of a file. Is this possible? I need to be able to quickly access and confirm its extension against its file type (which is as far as i know defined by its hex value).

Thanks,

/Jonny
Nov 16 '05 #1
3 2119
"=?Utf-8?B?Sm9ubnk=?=" <Jo***@discussions.microsoft.com> wrote in
news:92**********************************@microsof t.com:
Hi all,

I need to find out the hex value of a file. Is this possible? I need
to be able to quickly access and confirm its extension against its
file type (which is as far as i know defined by its hex value).


What is "file type" in this context ?

If I read this question correctly, you want to check if a file has the
correct file extension (like .AVI) depending on the content ? If that's
correct, then no, there is no single way of doing this.

Most files store some kind of signature at the very start so that the
program that use the file can easily check if the file is correct or not.
However, some files doesn't store the signature at the very start and some
files has it at the end, some just a checksum, etc.

In short, there's no "hex value" for a file that uniquely identifies its
type.

However, it might be that I misunderstood your question, in which case
ignore this reply :)

--
Lasse Vågsæther Karlsen
la***@vkarlsen.no
PGP KeyID: 0x0270466B
Nov 16 '05 #2
Hi Jonny,

I never heard of a hex value for a file (which doesn't necessarily mean it doesn't exist). The only way you can be absolutely sure what kind of file it is, is to try to read it (and in some cases you can't even be sure then). For image files, the first bytes of the file typically indicate what type of image file it is, something some image viewers take advantage of, displaying the correct image despite having the wrong file extension.

For a given file type, see if the first bytes of the file is the same as expected for that file type.

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
Ay thats what I meant, apologies for not being clear.

Thanks for your help.

--
/Jonny
"Lasse Vågsæther Karlsen" wrote:
"=?Utf-8?B?Sm9ubnk=?=" <Jo***@discussions.microsoft.com> wrote in
news:92**********************************@microsof t.com:
Hi all,

I need to find out the hex value of a file. Is this possible? I need
to be able to quickly access and confirm its extension against its
file type (which is as far as i know defined by its hex value).


What is "file type" in this context ?

If I read this question correctly, you want to check if a file has the
correct file extension (like .AVI) depending on the content ? If that's
correct, then no, there is no single way of doing this.

Most files store some kind of signature at the very start so that the
program that use the file can easily check if the file is correct or not.
However, some files doesn't store the signature at the very start and some
files has it at the end, some just a checksum, etc.

In short, there's no "hex value" for a file that uniquely identifies its
type.

However, it might be that I misunderstood your question, in which case
ignore this reply :)

--
Lasse Vågsæther Karlsen
la***@vkarlsen.no
PGP KeyID: 0x0270466B

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of...
2
by: Steve | last post by:
Hi, I have a very long string, someting like: DISPLAY=localhost:0.0,FORT_BUFFERED=true, F_ERROPT1=271\,271\,2\,1\,2\,2\,2\,2,G03BASIS=/opt/g03b05/g03/basis,...
5
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the...
22
by: Tony Houghton | last post by:
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use "~/.bombz", in Windows something like "C:\Documents...
11
by: spideyman99 | last post by:
How can I find the true EOF for a file that contains 0xFF. When I use fgetc and it encounters 0xFF it thinks it's the end of file but it really isn't.
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
9
by: Dave Booker | last post by:
When I run a particular application I've been working on for a while, it somehow finds a value for the Application Setting "Test.Properties.Settings.Default.ProjectPath", but I can't see where it...
0
by: NSF12345 | last post by:
Iv developed a small program that looks for a file over our network, and copy it to the location of another computer. Im using the "If FileExists("\\oldpc\main share\Folder\file.txt") Then" way of...
3
by: Rico | last post by:
Hello, I have a generic process that logs errors from different sources. When I call this code, I'd like to also submit the name of the function or sub that is raising the error without having...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.