Converting to Xojo.Net.HTTPSocket

@Paul Lefebvre
I took your RestTester project and am using it as an example. I have in my app an auto updater, and Wass using HttpSocket. Then it started acting up and was told by @Tim Parnell That I should move to the new frame work as newer servers may not work at all with the classic. I took you Tester and put the url of the file that updates my app and it downloaded it perfectly.

So I started changing things and the line DLHttp.Send(“Get”, mDownloadURL.ToText, downloadFile) is giving me the compile error: “There is more than one item with this name and it’s not clear to which it refers” (I hate that error!)

DLHttp is a Xojo.Net.HTTPSocket, draged on form.
mDownload is a string
download file is a FolderItem

I am totally lost as to where the problem is.

Thanks all!

It may be getting confused with the String.ToText right as a parameter. See if breaking it out helps:

dim txDownloadURL as Text mDownloadURL = DefineEncoding(mDownloadURL, Encodings.UTF8) txDownloadURL = mDownloadURL.ToText DLHttp.Send("Get", txDownloadURL, downloadFile)

Well tried that, same thing. I just don’t understand that stupid message. Why doesn’t it show you what it item it considers the same.

Is downloadFile a Xojo.IO.FolderItem?

That would be a very handy feature!

@Paul Lefebvre

We’ll no it isn’t. Let me try that.

Well changing that has caused a cascade of errors, 2 of which are the same error on a different line.

I think I’m going to have to roll back, as I made too many changes.

@Tim Parnell @Paul Lefebvre

I’m back where I started:

I will get back to it after Thanksgiving…

Any more ideas let me know.


That thread is not available… Is it possible to post the code?

Will do


I have an httpsocket that’s purpose is to download an update to my program. This has literally been working for over 4 years.

Suddenly it fires the error method off with the error code 1. I looked that up and it’s supposed to be Operation not permitted.

So I took the url the app is using to download and put that in the browser, it downloaded fine.

Does anybody have an idea on how to figure this out?


I accidentally started the thread in XoJo Pro.

What are the errors? They could be more illuminating than “1”

They all had to do with Expecting a Xojo.IO.FolderItem but was a folder item and Expecting Text when getting a string.

I think I may look at that updater afterall.

I looked at that updater and it’s using the classic HttpSocket. So I don’t see a reason to put that one in.

You’ll definitely have to convert things to the correct class/type.

To convert a classic FolderItem to a Xojo.IO.FolderItem:

Dim newFile As New Xojo.IO.FolderItem(classicFile.NativePath.ToText)

@Paul Lefebvre

Is Classic.NativePath.ToTest a classic folder item and after the statement newFile will have the value of the classic one?

Yes, classicFile is a classic FolderItem. That line of code uses the Xojo.IO.FolderItem Constructor to create a new Xojo.IO.FolderItem that points to the same file.

@Paul Lefebvre

Got 2 Problems:

Moving along however I got the Dreaded “There is more than one item with this name and it’s not clear to which this refers”

Dim downloadFileName As String
If Not mUseActualFilename Then
  #If TargetMacOS Then
    downloadFileName = "MemberTree.pkg.dmg"
    downloadFileName = "Setup.exe"
  // Use the actual filename from the XML
  Dim file() As String
  file = mDownloadURL.Split("/")
  downloadFileName = file(file.Ubound)
End If

Dim downloadFile As FolderItem
downloadFile = mDownloadLocation.Child(downloadFileName)

Dim newFile As New Xojo.IO.FolderItem(downloadFile.NativePath.ToText)
'MsgBox ("URL:" + mDownloadURL + " Downloadfile: " + downloadFile.AbsolutePath)
'DownloadSocket.Yield = False

DownloadSocket.Send("GET", mDownloadURL, newFile)    <<<<<<<<<<<<<<<<<<<<<<Error here

Me.ActionButtonEnabled = False

DownloadSocket is a Xojo.Net.HTTPSocket

Is there a way to convert an xojo.IO.Folderitem Back to a classic folderitem?

From the RecievedFIle event I call this:

LaunchFile(installer As FolderItem)
#If TargetWin32
  Soft Declare Function ShellExecuteA Lib "Shell32" (hwnd As Integer, operation As CString, _
  file As CString, params As CString, directory As CString, show As Integer) As Integer
  Soft Declare Function ShellExecuteW Lib "Shell32" (hwnd As Integer, operation As WString, _
  file As WString, params As WString, directory As WString, show As Integer) As Integer
  Dim params As String
  params = ""
  Dim intReturnCode as Integer = 0
  If System.IsFunctionAvailable("ShellExecuteW", "Shell32") Then
    intReturnCode = ShellExecuteW(0, "runas", installer.AbsolutePath, params, "", 1)
    intReturnCode = ShellExecuteA(0, "runas", installer.AbsolutePath, params, "", 1)
  End If
  If intReturnCode = 5 Then
    Return False
    Return True
  End If
  Dim lfile as FolderItem
  installer.Launch  'Launch dmg, which mounts the disk image
  lfile =  GetFolderItem("MemberTree:MemberTree.mpkg:", 0)
  lfile.Launch    'launch the actual pkg file
  Return True

Thanks for your help!!!

For number 1 is mDownloadURL Text or String? It needs to be Text for the new socket.
For number 2 you would do the same process in reverse. Xojo.IO.FolderItem.Path as Text, convert Text to String, use the path string as a NativePath to construct a classic framework FolderItem.

And please, stop using AbsolutePath.

It’s deprecated for removal (and IMO should have been removed already)