Hi, I'm trying to write the code to allow users to browse to a file location on our servers and select a file, but instead of attaching that file I want just the link to be embedded. The users have been attaching too many files to the forms and it's getting bogged down by slow load times, so I want to see if this can speed up load times on the forms. I've put a repeating Hyperlink section on the form, and a button below it. The code is going behind the button.
I got the browse window to pop up easy enough and locate the file URL, but I can't seem to get the navigator to interact with the XML (these are browser-enabled forms, for putting into a MS SharePoint library, if that makes a difference).
Here's what I have so far...
Public Sub CTRL203_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "\\Server\People\mduval"
openFileDialog1.Filter = "All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim uri As New Uri(openFileDialog1.FileName)
System.Diagnostics.Debug.Print(uri.OriginalString)
Dim navigator As XPathNavigator = MainDataSource.CreateNavigator()
Dim links As XPathNavigator = navigator.SelectSingleNode("/my:myFields/my:IWDiligences/my:IWDiligenceLinks", NamespaceManager)
System.Diagnostics.Debug.Print(links.Name)
Dim attach As XmlReader = XmlReader.Create(New IO.StringReader("<IWDiligenceLink>" + uri.OriginalString + "</IWDiligenceLink>"))
links.AppendChild(attach)
links.MoveToParent()
System.Diagnostics.Debug.Print("Test: " + links.OuterXml)
End If
End Sub
If this is something someone else has done, feel free to just link me to it. I couldn't find something similar anywhere, but there's no need to repeat yourself if you've solved it for somebody else. Also, not sure why this text just turned blue...but I'll leave it anyways. Thanks!
Edit: Also, is there a way to format this text so that it doesn't get thrown out into block quotes like that?