Hi,
I’m having a strange problems using Xojo.net.HTTPSocket.
I download html pages and images from websites. To cache the files, I save them into a subfolder in SpecialFolder.Preferences for PC or SpecialFolder.ApplicationData for Mac
I call my Xojo.Net.HTTPSocket with something like this :
Dim newPath As New Xojo.IO.FolderItem(PreferencesGetTemporaryFolder.NativePath.ToText) // PreferencesGetTemporaryFolder returns the classic path
outputFile = newPath.Child( GenerateUUID.ToText ) // Create unique name for cache file
ScriptRecherche.FileCache.Value( url ) = outputFile // Save the name in a dictionary key = url, value = FolderItem
WRechercheInternet.XojoSocketListe.Send(methode.ToText, url.ToText, outputFile ) // Call the socket. methode = GET
On Mac there’s no problems. But on Windows … it depends ! Some users said that they got an error message. After verifying, that’s because the fil is not created. I know the the app has access to the folder, because I’m writing a lot of files in it (with classic HTTPScocket or just from local data)
The Xojo.Net.HTTPSocket fires the FileReceived event. I’ve added control code in the Error event but this event is not called. But there’s no file in the folder.
I’ve tried using the PageReceived method and write the file myself :
[code]Dim contentData As Text
contentData = Xojo.Core.TextEncoding.FromIANAName( ListeTitres.Encodage ).ConvertDataToText( content )
Dim outputFile as Xojo.IO.FolderItem
Dim newPath As New Xojo.IO.FolderItem(PreferencesGetTemporaryFolder.NativePath.ToText)
outputFile = newPath.Child( GenerateUUID.ToText )
Dim output As TextOutputStream
Try
Dim encoding As Xojo.Core.TextEncoding
encoding = Xojo.Core.TextEncoding.FromIANAName( ListeTitres.Encodage )
output = TextOutputStream.Create( outputFile, encoding )
output.Write Content
output.Close
Catch err As IOException
… (show error code)
End Try
[/code]
The err.code =0 and the err.Message is “The file could not be created” (I suppose the FileReceived had the same problem)
I’ve also try to use SpecialFolder.Temporary … with the same error !
I’m not sure this is because of some antivirus software. I don’t know how many of my PC users have this problems. Of course, I’ve no problem with all my test machine (VM W7, VM W10, VM W10 with Avast, Surface 3)
There’s no problem downloading and writing file with classic framework on the same location. Can it be a problem with the new Xojo framework ? I’m very confused…