# A way to check if the file is all there?

**URL:** <https://www.finalbuilder.com/forums/t/a-way-to-check-if-the-file-is-all-there/4481>\
**Category:** Discussion\
**Created:** [July 19, 2011, 5:14am UTC](https://www.finalbuilder.com/forums/t/a-way-to-check-if-the-file-is-all-there/4481 "2011-07-19T05:14:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)\
**Post date:** [July 19, 2011, 5:14am UTC](https://www.finalbuilder.com/forums/t/a-way-to-check-if-the-file-is-all-there/4481/1 "2011-07-19T05:14:12Z")

</div>

Is there a way to check if the file is all there?

For example a 300 mb file is being downloaded by some other automated FTP&nbsp;program and the automise script kicks off. Is there a way to check that the file is "not all there"&nbsp;and fail the job?

---

<div class="post-metadata">

**Author:** ![stephen.ryan](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@stephen.ryan](https://www.finalbuilder.com/forums/u/stephen.ryan)\
**Post date:** [July 21, 2011, 9:14am UTC](https://www.finalbuilder.com/forums/t/a-way-to-check-if-the-file-is-all-there/4481/2 "2011-07-21T09:14:02Z")

</div>

Hi   
  
 This may be difficult to determine without some information about the file prior to the download (size or checksum). If you can get the checksum for the file before the download then you can compare this information once the download has completed.   
  
 Regards,   
 Steve

---

<div class="post-metadata">

**Author:** ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)\
**Post date:** [July 21, 2011, 8:47am UTC](https://www.finalbuilder.com/forums/t/a-way-to-check-if-the-file-is-all-there/4481/3 "2011-07-21T08:47:22Z")

</div>

&nbsp;If the file is being written by some other program that it will have the "lock" right? Is there a way to tell if a "lock" exists on that file maybe?

---

<div class="post-metadata">

**Author:** ![stephen.ryan](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@stephen.ryan](https://www.finalbuilder.com/forums/u/stephen.ryan)\
**Post date:** [July 29, 2011, 7:29am UTC](https://www.finalbuilder.com/forums/t/a-way-to-check-if-the-file-is-all-there/4481/4 "2011-07-29T07:29:05Z")

</div>

Possibly, you maybe able to use a simple script to check if the file is locked.   
  
I have used a script such as this in the past (VBScript)..   
  
Const ForReading = 1  
Const ForWriting = 2  
Const ForAppending = 8  
  
Dim fsObject  
Dim fileObject  
Dim textStream  
Dim fileName  
  
On Error Resume Next  
  
Set fsObject = CreateObject("Scripting.FileSystemObject")  
  
' Set Filename here of a file to check for locking  
fileName = "C:\Build\_Env\7.3.2\_STR\Installs\Install\Disk1\setup.exe"  
  
If Not FileExists(fileName) Then  
&nbsp;&nbsp; Action.SendLogMessage "File Does Not Exist " & fileName, stInformation  
&nbsp;&nbsp; Exit Sub  
End If  
  
Set fileObject = fsObject.GetFile(fileName)  
Set textStream = fileObject.OpenAsTextStream(ForAppending, -2)  
If Err.Number = 70 Then  
&nbsp; Action.SendLogMessage "File Locked: " & fileName, stError  
&nbsp; ActionResult = False  
&nbsp; Exit Sub  
End If  
Err.Clear  
  
Action.SendLogMessage "File Not Locked: " & fileName, stSuccess
