C# code to open network file browser form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

C# code to open network file browser form

Last post 09-09-2013 08:12 AM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 09-03-2013 11:15 PM

    C# code to open network file browser form

    Hi, I had a question that I'm wondering is possible. I wanted to be able to have a button on a form that opens a specific file on a network drive. The network drive path is all specified through group policy, so everyone will have it mapped the same way (P:\ drive in this instance). I had created a view in one field that would allow the data input person to input the file path of the file specified in, and on another view, I created a button to open the file via the default application. I deployed the form via full trust and published to my SharePoint site. For reference, the code behind the button is below (pretty simple):

    public void CTRL2_5_Clicked(object sender, ClickedEventArgs e)

    {

    // Write your code here.

    XPathNavigator nav = MainDataSource.CreateNavigator();

    string fieldValue = nav.SelectSingleNode("//my:myFields/my:field1", NamespaceManager).Value;

    System.Diagnostics.Process.Start(fieldValue);

    }

    If I run this in infopath filler it works great. However, I've come to realize as I'm chasing down errors that the code is executed from the server and even if a valid file is inputted from the server's point of view, the file will not actually open on the users computer. Is there a better way to achieve what I am looking for here? I want to make working with this form as EASY as possible in order to drive adoption of this through my company, so I thought the button solution would be great. Rolling out infopath filler to everyone in my environment is not a realistic option. Does anyone have a bead one a work-around, or see what I am missing? If I am going about this in the wrong manner I'm open to any suggestions (i.e. is it possible to attach the file I want to open via button to the sharepoint form, and open it with one button push that way?, etc.). I would greatly appreciate any help anyone can offer in this regard. I am sorry for the formatting on this post, I am unclear how to format here, and unfortunately was unable to find a topic pointing me in the right direction. Thank you in advance for your time.

  • 09-08-2013 02:51 PM In reply to

    Re: C# code to open network file browser form

    Why not just insert a link to the specific file on the InfoPath form. Then, the users can click the link and open the file. Easy, no code or full trust needed.

    :)

    Patrick Halstead
    Project Manager at Qdabra
  • 09-08-2013 03:03 PM In reply to

    Re: C# code to open network file browser form

    Thank you for your response. Do you mind showing me a simple example? Ideally I would like my users who aren't inputting the data to only view the file, not be able to change it at all (i have 2 views already set on the form). You're sure it would work even when running from the server? I'm not at work at the moment and sorry if these questions seem extraordinarily noobish...
  • 09-09-2013 08:12 AM In reply to

    Re: C# code to open network file browser form

     A URL (link) would open on the user's machine. Not sure what you could do to make the file read only - perhaps put the file in a SharePoint library and use permissions there?

    Hilary Stoupa

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.