Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

InfoPath: How do I show local path of attached file instead of attaching the physical file

When using the file attachment control in a 2007 InfoPath form, I want to display the local path where the file was attached instead of attaching the actual file itself.  The path could be a network location, shared drive, etc. and we'd like the path to be 'clickable'.

I've looked around and found ways to get the filename but it doesn't say how to get the entire local file path.  I'm assuming I have to use the file control because we want the browse capability.
  • 2
  • 2
1 Solution
Brenda DBusiness Systems AnalystCommented:
You can create an Hyperlink link from the control panel and enter the path to the file.  enter the Drive letter and then the filename. I.e. H:\12345.docx.

When the user clicks on the hyperlink it will open the file up from that location.
skipper68Application Development ManagerAuthor Commented:
Thanks Brenda but I had thought this question was deleted due to no responses.  Anyway, here's how I did it for anyone who is having the same problem:
I had to create a button that utilized form code which allowed you to trap the file selection window and get the path of the file which I ultimately put in a URL formatted text box:
AddHandler DirectCast(EventManager.ControlEvents("CTRL77_5"), ButtonEvent).Clicked, AddressOf CTRL77_5_Clicked

Public Sub CTRL77_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
            Dim OFD As OpenFileDialog = New System.Windows.Forms.OpenFileDialog
            OFD.Title = "Select A File"
            If OFD.ShowDialog() = DialogResult.OK Then
                Dim sr As New System.IO.StreamReader(OFD.FileName)
                Dim nav As XPathNavigator = MainDataSource.CreateNavigator
                nav.SelectSingleNode("/my:myFields/my:field7", NamespaceManager).SetValue(OFD.FileName)
            End If
End Sub

Open in new window

This however raised another issue because it was a server side form which was trying to access local resources.  That meant I had to use a Code Signing Certificate to sign the form which was an entirely different issue. :-)
Brenda DBusiness Systems AnalystCommented:
excellent job on the coding. thank you for the update.
skipper68Application Development ManagerAuthor Commented:
See my solution above.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now