Pergunta

I designed a purchase requisition form for my company that has been working out really great; however, management wants one more piece of functionality to the form. They essentially want a "save form" button that they can click which will automatically open a "save aswindow whenever they want to save the form. Not only that, but they want the default folder that pops up in thesave asbox to be a networked drive (E.g.\\servername\dept shares\approved PRs`). I know that this is basically circumventing a few extra clicks with the baked in MS Office save functionality, but it's what they want in order to "reduce human error".

I looked up some ways to program the button using C#, but I seem to be missing something (I am a novice programmer). For example, just to see if I can even get a save function to work at all on the button, I tried using the recommended:

using System.XML.Linq;

XDocument.save();

After debugging, I get:

System.Xml.Linq.XDocument does not contain a definition for save.

I figured I'm not calling the correct reference. I'm stuck! Anyone out there that can shed some light on this? I guess at this point I just want to be sure it's even possible to make a save button at all, let alone have it default to a shared network drive. My apologies if this seems painfully basic.

Foi útil?

Solução

You'll need to use Microsoft.Office.Interop.InfoPath instead of System.XML.Linq. The infopath reference does contain a .Save() reference, hopefully the rest of the example you've found should help from then on.

If not, you might want to look at referencing System.Windows.Forms and using SaveFileDialog to allow the user to select their path.

        SaveFileDialog dialog = new SaveFileDialog();
        dialog.InitialDirectory = @"\\servername\share";
        dialog.ShowDialog();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top