How to check gz file is read only

I am compressing the large size CSV file to Gz file before uploading into Amazons3. I need to check whether the file ready to move.

I tried to use Get file info activity to check gz file is read only or not, but the activity not working, always in False status

Hi,

Do you try to know if the file is completed to write by ReadOnly attribute? Unfortunately, ReadOnly attribute is one of file system attributes and it doesn’t reflect file is being written or not.

So it’s necessary to use other approach. For example, get the file size at intervals of a few seconds, and if there is no change, determine that the write operation is complete.

Regards,

Are there any scripts to check the file size at intervals of a few seconds?

Hi @rumabharathy

Try this-

  1. Use the “Invoke Code” activity in your workflow.
  2. In the “Invoke Code” activity, you can use the following VB.NET code to check if the Gzipped file is read-only:

Imports System.IO

Dim gzFilePath As String = “path_to_your_gz_file.gz”

Dim fileInfo As New FileInfo(gzFilePath)

If fileInfo.IsReadOnly Then
’ File is read-only
Throw New Exception(“The Gzipped file is read-only.”)
Else
’ File is not read-only
’ You can continue with your process
End If

Replace "path_to_your_gz_file.gz" with the actual file path of your Gzipped file.

Thanks!!

@Nitya1 I tired the above script

I tested the csv file which was not fully loaded but File info always going to “Ready” status.

Dim gzFilePath As String = Pathtogzfile

Dim fileInfo As New FileInfo(gzFilePath)

If fileInfo.IsReadOnly Then
returnMessage =String.Concat(“READ ONLY”)
Else
returnMessage =String.Concat(“READY”)
End If

@Yoichi In the system , I checked the Properties of the file, it is always in Archive mode even the CSV file not fully loaded and not ready to use
image

Hi,

Archive flag is always added if the file is created or modified. Basically, it has nothing to do with whether we can read the file or not.

Are there any scripts to check the file size at intervals of a few seconds?

The following sample helps you.

Sample20230920-1L.zip (2.9 KB)

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.