Ok, I think for the sake of comments and responses - I'm going to add anohter post here.
(if I am supposed to edit my original post - then my apologes to this forum and group - just not sure which is perfered).
As I noted, the real goal here is to take the existing treeview, and "convert" or "modify" or at the very least cook up a way to get the existing URL's with that "no more" supported file setting in the URL link.
We can actually approach this problem like this:
Is there a way to get that URL sent to the server, grab the URL, convert into a full plane jane server path name, and THEN use the information in my first post to stream (read + send) the file down to the browser.
The old story comes down to this:
How do you eat an elephant?
Answer: one bite at a time.
so, if we can get/grab/see/have that old URL and grab it?
Then we can add code to the page - and not have to modify on a link by link bases (it would not make sense to add 100's of link buttons - too much work).
So, assume this simple treeview and assume it has the old style "file" path names.
Lets keep this simple as possible. So, we have this markup:
Ok, so now what we do is add a wee bit of javascript to PROCESS the treeview, remove the URL, and convert that URL into a simple click event. That click event can then run server side code and dish out the file.
So we add this JavaScript code to the page:
So, what above does is converts the URL navagate into a on-click. The routine when clicked then simple shoves the URL (path) into a hidden control, and THEN clicks our button (you eventually hide that button with style="display","none").
So, now our code behind is this:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strServerFile As String = hFileLink.Value
strServerFile = strServerFile.Replace("/", "\")
Call SendFile(strServerFile)
End Sub
Sub SendFile(strFile As String)
Dim strServerFile As String = strFile.Replace("file://", "")
Dim sFileNameOnly = Path.GetFileName(strServerFile)
Dim sMineType As String = MimeMapping.GetMimeMapping(sFileNameOnly)
If File.Exists(strServerFile) Then
Dim binFile As Byte() = File.ReadAllBytes(strServerFile)
Response.ContentType = sMineType
Response.AppendHeader("Content-Disposition", "inline; filename=" + sFileNameOnly)
Response.BinaryWrite(binFile)
Response.End()
End If
End Sub
So, what this means, is we don't have to modify each link in the treeview, but apply some code to the exising TV, wire up that server side event, and then we free to use the first bits and parts I posted in my other answer.
The only thing that looks out of place here is the "file" path name(s) you have - they don't look like a "resolve" or path name to the exsting server - but the above approach, and ideas, and concepts should be albe to work here, and this means that we don't have to change the existing treeview much - but just apply some js code that changes it to what we need for this to work in modern browsers.
Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada