Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:05:33+00:00 2026-05-14T15:05:33+00:00

I have a FAT drive, lets say H: and a directory ‘work’ (full path

  • 0

I have a FAT drive, lets say H: and a directory ‘work’ (full path ‘H:\work’). I need to get the NUMBER of the first cluster of that directory. The number of the first cluster is 2-bytes value, that is stored in the 26th and 27th bytes of the folder entry (which is 32 bytes).

Lets say I am doing it with file, NOT a directory. I can use code like this:

 static public string GetDirectoryPtr(string dir)
    {
        
        IntPtr ptr = CreateFile(@"H:\Work\dover.docx",
            GENERIC_READ,
            FILE_SHARE_READ | FILE_SHARE_WRITE,
            IntPtr.Zero,
            OPEN_EXISTING,
            0,//FILE_FLAG_BACKUP_SEMANTICS, 
            IntPtr.Zero);
        try
        {
            const uint bytesToRead = 2;
            byte[] readbuffer = new byte[bytesToRead];
            if (ptr.ToInt32() == -1) return String.Format("Error: cannot open directory {0}", dir);
            if (SetFilePointer(ptr, 26, 0, 0) == -1) return String.Format("Error: unable to set file pointer on file {0}", ptr);

            uint read = 0; // real count of read bytes
            if (!ReadFile(ptr, readbuffer, bytesToRead, out read, 0)) return String.Format("can't read from file {0}. Error #{1}", ptr, Marshal.GetLastWin32Error());                
            int result = readbuffer[0] + 16 * 16 * readbuffer[1];
            return result.ToString();//ASCIIEncoding.ASCII.GetString(readbuffer);

        }
        finally
        {
            CloseHandle(ptr);
        }
    }

And it will return some number, like 19 (quite real to me, this is the only file on the disk).

But I DON’T need a file, I need a folder. So I am putting FILE_FLAG_BACKUP_SEMANTICS param for CreateFile call… and don’t know what to do next. Is there any way to get it working for a folder?

msdn is very clear on this issue http://msdn.microsoft.com/en-us/library/aa365258(v=VS.85).aspx

It sounds to me like: "There is no way you can get a number of the folder’s first cluster". The most desperate thing is that my tutor said something like "You are going to obtain this or you wont pass this course". The true reason why he is so sure this is possible is because for 10 years (or may be more) he received the folder’s first cluster number as a HASH of the folder’s address (and I was stupid enough to point this to him, so now I can’t do it the same way)

PS: This is the most stupid task I have ever had! This value is not really used anywhere in program, it is only a pointless integer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:05:34+00:00Added an answer on May 14, 2026 at 3:05 pm

    So if I understand correctly, you want to read the FAT and get the first cluster of a directory on the disk?

    If the above is correct, then it might be better to open the volume for direct access.
    http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx
    See the section on Phystical Disks and Volumes.

    Once you have the volume open you can then read the disk sectors and scan the FAT to locate the entry for the directory you are interested in.

    Here is a sample of using DeiceIoControl to read the disk geometry.
    http://msdn.microsoft.com/en-us/library/aa363147(VS.85).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fat GUI that it getting fairly complex, and I would like
I have a classic client/server (fat client and database) program written in Delphi 2006.
Outline OK, I have Google'd this and already expecting a big fat NO!! But
Have you determined a maximum number of characters allowed in FCKEditor ? I seem
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have a n-tire web application and search often times out after 30 secs. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.