Hello All,
The following snippet of codes is from the Action event of a web button “Open File” on a modal dialog (to deal with downloading, viewing and uploading of attachments).
The intention of the web button action is to download a database blob into a file on the client computer, and to open it with the default program associated with the file on the same client computer.
In this example, I hard-coded the folder and file names.
TargetFolder = “c:\users\shusin”
tStr = “a test file.xlsm”
FileName = TargetFolder + tStr
fTarget = new FolderItem(FileName, FolderItem.PathTypeShell)
dim bs as BinaryStream = BinaryStream.Create(fTarget, true)
If bs <> nil then
bs.write(blob)
bs.close
Dim ff As new Folderitem(FileName, FolderItem.PathTypeShell)
If ff <> nil and ff.Exists Then
Dim DownloadFile As WebFile
DownloadFile = new WebFile
DownloadFile = WebFile.Open(ff)
DownloadFile.ForceDownload = True
Call DownloadFile.Download
MsgBox(fTarget.URLPath) //#1
Me.ShowURL(fTarget.URLPath, True) //#2
End If
End If
When executed, #1 (from Msgbox above) shows: file:///c:/Users/shusin/a%20test%20file.xlsm, as expected.
Also, by the time this message popped up, I could see the file had been downloaded successfully in the target folder, and I could open it (in Excel) when I double-clicked on it in Windows explorer.
However, #2 (from ShowURL) was not successful. Firstly, it did not launch in a new window (as specified w/ True in the second parameter), and secondly, it failed with HTTP 404 Not Found.
The URL of this launched page was: http://127.0.0.1:2222/9E776B75A04049BF39DB6FF0D6D96DD3510CB6FD/files/2947-3757-0851-1744-1518/a%20test%20file.xlsm
What do I do wrong here? Any guidance and suggestions are welcome. FYI, I am still using version 2018 release 2, for company policy reasons.
-Simon