Announcement

Collapse
No announcement yet.

File.SetAttributes and error code 1038 (Could not set file's compressed attribute.)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • File.SetAttributes and error code 1038 (Could not set file's compressed attribute.)

    I've got some files that I download from our website during install and install as read-only. This works. However, I noticed in the Debug log that they are all still throwing an error on the SetAttributes call with error code 1038.

    Code is as follows:

    Code:
    local file_path = SessionVar.Expand("%AppFolder%\\SampleFiles\\") .. "file.ext";
    local file_attributes_table = File.GetAttributes(file_path);
    if (Application.GetLastError() ~= ERROR_SUCCESS) then
        Debug.Print(string.format("Failed to get file attributes.  Error Code:%d (%s)\r\n", Application.GetLastError(), _tblErrorMessages[Application.GetLastError()]));
    else
        file_attributes_table.ReadOnly = true;
        File.SetAttributes(file_path, file_attributes_table);
        if (Application.GetLastError() ~= ERROR_SUCCESS) then
            Debug.Print(string.format("Failed to set file attributes.  Error Code:%d (%s)\r\n", Application.GetLastError(), _tblErrorMessages[Application.GetLastError()]));
        end
    end
    I have tried also setting:

    file_attributes_table.Compressed = false;

    as well but I still get the same error on the File.SetAttributes call.

    As I mentioned initially, the code works as expected (the files do get set to read-only) and I don't see the error anywhere except the debug log so it is a pretty minor issue. I don't want the files to be compressed but ideally, I would like the error to go away. I'm only posting here mainly to make sure that I'm not doing something fundamentally wrong here.

    I'm testing on Win10 currently.

    Is this expected behavior?
Working...
X