I'm using AuthorizationMBS to write a file if the user can't write to a specific location. The executed script is just a ditto to copy a file from the temporary folder to the final location. I now got a user who can't create the temporary file. The code
dim tempFile as FolderItem = SpecialFolder.Temporary.Child(theRegisterFile.Name) dim theBinStream as BinaryStream = BinaryStream.Open(tempFile, true)
makes an exception. Therefore, I tried to make the temp file in a different way
dim tempFile as FolderItem = GetTemporaryFolderItem tempFile.Name = theRegisterFile.Name
That the file doesn't have the correct name is a minor problem. But now the AuthorizationMBS writes a file with 0 bytes. What am I doing wrong? Full code below with error handling omitted:
'get script dim InternalFolder as FolderItem = app.ExecutableFile.Parent.Parent if InternalFolder <> nil and InternalFolder.Exists then InternalFolder = InternalFolder.Child("Resources") if InternalFolder <> nil and InternalFolder.Exists then InternalFolder = InternalFolder.Child("write launch agent file.sh") dim tempFile as FolderItem '= SpecialFolder.Temporary.Child(theRegisterFile.Name) tempFile = GetTemporaryFolderItem tempFile.Name = theRegisterFile.Name try dim theBinStream as BinaryStream = BinaryStream.Open(tempFile, true) theBinStream.Write theText theBinStream.Close catch err as IOException Return False end try 'do Authorization dim theAuthorisation as new AuthorizationMBS if not theAuthorisation.SimpleNewAuthorization thenReturn False dim s(-1) as string s.Append(tempFile.UnixpathMBS) s.Append(theRegisterFile.Parent.UnixpathMBS) theAuthorisation.Execute(InternalFolder.UnixpathMBS, s, true) if theAuthorisation.LastError = 0 then dim theResult as Integer = theAuthorisation.Wait Return True else Return False end if