GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Jan-2009, 17:40
BobLewiston BobLewiston is offline
Junior Member
 
Join Date: Nov 2008
Posts: 46
BobLewiston is on a distinguished road

Identifying file types


Within a C# program, is there any way to tell if a file is a text file or not? I mean a real way, not just basing your conclusion on a file name extension.
  #2  
Old 06-Apr-2009, 07:43
erniegerdie erniegerdie is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: England
Posts: 93
erniegerdie has a spectacular aura abouterniegerdie has a spectacular aura about

Re: Identifying file types


It would be in the file header, its the first x bytes (I can't remember how many 'x' is - maybe 2).

Test by, creating a text file, read it into a byte array and check the first two bytes.

Then create another one and see if it matches the first two bytes. If so you've got your file signature.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
After execution - Error cannot locate /Skin File? WSCH C++ Forum 1 05-Mar-2005 21:03
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28
CD Buring Failed skanth2000 Computer Hardware Forum 1 15-Nov-2003 04:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:24.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.