Delphi Check File Size

Posted on by
Delphi Check File Size Average ratng: 5,0/5 9232 votes

Function FileSize ( var FileHandle: File; ): Integer; Description. The FileSize function gives the size in records of an open file. Before this function can be used, the file must be assigned a handle by using AssignFile and opened using Append, Reset or ReWrite routines. The FileSize function returns the size of a file, in bytes -- a useful result for certain file-handing applications within a Delphi program. Get File Size The FileSize function returns the size of a file in bytes; the function returns -1 if the file was not found. Use the Win32 API SHChangeNotifyRegister function to watch for changes in the temp folder, and then have your callback check if your temporary files are reporting changes. Since you know the exact file(s) you are interested in, you can manually monitor them directly for changes to their sizes and timestamps using FindFirstFile in a timer or thread. I am trying to check whether a text file is empty or not. There is a function in TP which is called 'FileSize' that can be used to get the size of the file in byte. Unfortunalety this function cannot be used for text file. Does anybody know a way of writing similar function for text files. Delphi Programming; idFTP client - checking it the files exist. IdFTP client - checking it the files exist Hi! Is there any way to check if the file that the user wants to upload already exists on this server? Thanks for all advices, Stander Faq. November 9th, 2005, 07:27 PM #2. View Profile.

Active8 years, 4 months ago

My app contains documents in its database. The users can open the documents in which case, the document gets saved to a temporary folder and gets opened on the user's computer.

I'd like to get a notification when one of these temporary files are changed, and offer the user to save the changed document back to the database.

What is the most simple way to do this in Delphi7? (I suppose it requires some shell magic or 3rd party component)

Thanks!

RRUZ
125k13 gold badges314 silver badges446 bronze badges
SteveSteve
1,3112 gold badges22 silver badges47 bronze badges

4 Answers

You can either:

  1. use the Win32 API SHChangeNotifyRegister function to watch for changes in the temp folder, and then have your callback check if your temporary files are reporting changes.

  2. since you know the exact file(s) you are interested in, you can manually monitor them directly for changes to their sizes and timestamps using FindFirstFile in a timer or thread.

Remy LebeauRemy Lebeau
360k21 gold badges287 silver badges486 bronze badges

You can detect changes in your temporary files (or any file) using the TJvChangeNotify component from the JEDI JVCL collection.

RRUZRRUZ
125k13 gold badges314 silver badges446 bronze badges

In addition to what RRuz and Remy Lebeau wrote:

Note that TJvChangeNotify in the JvChangeNotify unit makes use of the FindFirstChangeNotification API call; this is the MSDN documentation. Note it is a bit counter-intuitive: see the thread mentioned below on how to use it inside a while loop.

(Please remember to honor your company's IT policies before installing new software!) • • • •. In order to provide the best platform for continued innovation, Jive no longer supports Internet Explorer 7. Teknik membuat cd autorun. Please consider upgrading to a more recent version of Internet Explorer, or trying another browser such as Firefox, Safari, or Google Chrome. Attention, Internet Explorer User Announcement: Jive has discontinued support for Internet Explorer 7 and below. Jive will not function with this version of Internet Explorer.

There is also the ReadDirectoryChanges API call, which is not wrapped by the JCL/JVCL, and has MSDN documentation here and there is a Delphi win32 example as well.

Delphi

This thread explains the differences between the two API calls.

--jeroen

Community
Jeroen Wiert PluimersJeroen Wiert Pluimers
20.9k5 gold badges53 silver badges133 bronze badges

Also take a look at this: http://www.cromis.net/blog/downloads/directory-watch/ and How to monitoring directory for files in Delphi XE?

Community
RobertFrankRobertFrank
5,3228 gold badges46 silver badges90 bronze badges

Not the answer you're looking for? Browse other questions tagged delphiwinapishellfile-iodelphi-7 or ask your own question.

Active8 years, 4 months ago

My app contains documents in its database. The users can open the documents in which case, the document gets saved to a temporary folder and gets opened on the user's computer.

I'd like to get a notification when one of these temporary files are changed, and offer the user to save the changed document back to the database.

What is the most simple way to do this in Delphi7? (I suppose it requires some shell magic or 3rd party component)

Thanks!

RRUZ
125k13 gold badges314 silver badges446 bronze badges
SteveSteve
1,3112 gold badges22 silver badges47 bronze badges

4 Answers

You can either:

  1. use the Win32 API SHChangeNotifyRegister function to watch for changes in the temp folder, and then have your callback check if your temporary files are reporting changes.

  2. since you know the exact file(s) you are interested in, you can manually monitor them directly for changes to their sizes and timestamps using FindFirstFile in a timer or thread.

Remy LebeauRemy Lebeau

Windows Check File Size

360k21 gold badges287 silver badges486 bronze badges

You can detect changes in your temporary files (or any file) using the TJvChangeNotify component from the JEDI JVCL collection.

RRUZRRUZ
125k13 gold badges314 silver badges446 bronze badges

In addition to what RRuz and Remy Lebeau wrote:

Delphi Check File Size Online

Note that TJvChangeNotify in the JvChangeNotify unit makes use of the FindFirstChangeNotification API call; this is the MSDN documentation. Note it is a bit counter-intuitive: see the thread mentioned below on how to use it inside a while loop.

There is also the ReadDirectoryChanges API call, which is not wrapped by the JCL/JVCL, and has MSDN documentation here and there is a Delphi win32 example as well.

This thread explains the differences between the two API calls.

--jeroen

Community
Jeroen Wiert PluimersJeroen Wiert Pluimers
20.9k5 gold badges53 silver badges133 bronze badges

Also take a look at this: http://www.cromis.net/blog/downloads/directory-watch/ and How to monitoring directory for files in Delphi XE?

Community
RobertFrank

Delphi Check File Sizes

RobertFrank

Python Check File Size

5,3228 gold badges46 silver badges90 bronze badges

How To Check File Size On Ipad

Size

Perl Check File Size

Not the answer you're looking for? Browse other questions tagged delphiwinapishellfile-iodelphi-7 or ask your own question.