Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to use Files Bigger than 2 gig Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
10-Jun-03
Category
Files Operation
Language
Delphi 2.x
Views
88
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: kray kray

Searching for files and get no problems when the size is greater than 2 gig

Answer:

The FindFirstFile / FindNextFile / FindClose APIs are used for searching for 
various files. 

When using these APIs it is important to remember that failing to close a Find can 
result in files or directories not being available for some operations (such as 
deletes). This is because these APIs open a handle to the objects being searched, 
and the operating system won't allow you to do certain things to an object as long 
as an active handle to that object exists.   

Also, the data structure used by these APIs contains string data, which is 
terminated by null characters. 

Example: 

1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     Handle: THandle;
4     s: string;
5     FD: WIN32_FIND_DATA;
6   begin
7     s := 'c:\*.*';
8     Handle := FindFirstFile(pchar(s), fd);
9     if Handle <> INVALID_HANDLE_VALUE then
10    begin
11      Memo1.Lines.Add(fd.cFileName);
12      while FindNextFile(handle, fd) = True do
13        Memo1.Lines.Add(fd.cFileName);
14    end;
15    Windows.FindClose(Handle);
16  end;


Finds the first file matching the wild file specifier. '*' can be used to match 0 
or more characters, '?' for a single character. If there are no wild specifiers in 
the string the function acts as a query for an explicit single file. The function 
works for both files and folders. 
The WIN32_FIND_DATA contains full information about the first matched file. 

dwFileAttributes File attributes (see CreateFile) 
ftCreationTime Time file created (see GetFileTime) 
ftLastAccessTime Time file last accessed 
ftLastWriteTime Time file last written to 
nFileSizeHigh Most significant 32bits of file size(see GetFileSize) 
nFileSizeLow Least significant 32bits of file size 
dwReserved0 O.S. specific data 
dwReserved1 O.S. specific data 
cFileName File name with extension within the folder 
cAlternateFileName Alternate shortened (8.3) form of name iff cFileName is not a 
valid MSDOS name 

The returned handle is passed to FindNextFile to get at the next matching file or 
folder. When the scan is completed FindClose must be used to close the handle. 

More Info: 

17  WIN32_FIND_DATA = record
18    dwFileAttributes: DWORD;
19    ftCreationTime: TFileTime;
20    ftLastAccessTime: TFileTime;
21    ftLastWriteTime: TFileTime;
22    nFileSizeHigh: DWORD;
23    nFileSizeLow: DWORD;
24    dwReserved0: DWORD;
25    dwReserved1: DWORD;
26    cFileName: array[0..MAX_PATH - 1] of AnsiChar;
27    cAlternateFileName: array[0..13] of AnsiChar;
28  end;


FILE_ATTRIBUTE_ARCHIVE 
The file is an archive file. Applications use this value to mark files for     
backup or removal. 

FILE_ATTRIBUTE_COMPRESSED 
The file or directory is compressed. For a file, this means that all of the data in 
the file is compressed. For a directory, this means that compression is the default 
for newly created files and subdirectories. 

FILE_ATTRIBUTE_DIRECTORY 
The file is a directory. 

FILE_ATTRIBUTE_HIDDEN 
The file is hidden. It is not included in an ordinary directory listing. 

FILE_ATTRIBUTE_NORMAL 
The file has no other attributes set. This value is valid only if used alone. 

FILE_ATTRIBUTE_OFFLINE 
The data of the file is not immediately available. Indicates that the file data has 
been physically moved to offline storage. 

FILE_ATTRIBUTE_READONLY 
The file is read-only. Applications can read the file but cannot write to it or 
delete it. 

FILE_ATTRIBUTE_SYSTEM 
The file is part of the operating system or is used exclusively by it. 

FILE_ATTRIBUTE_TEMPORARY 
The file is being used for temporary storage. Applications should write to the file only if absolutely necessary. Most of the file's data remains in memory without being flushed to the media because the file will soon be deleted. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC