Overriding the Default Save Location - InfoPath Dev
in

InfoPath Dev

Overriding the Default Save Location

Last post 10-12-2005 04:57 PM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-10-2005 06:08 PM

    • rjohnson
    • Top 500 Contributor
    • Joined on 09-02-2005
    • Australia
    • Posts 28

    Overriding the Default Save Location

    Hi,

    When loading a form from a saved XML, I want the user to start the default save location from the My Documents. I know this is the default behaviour when loading an XSN, but I also want this occur when loading an XML. By default, when I load an XML from the hard drive, or a submitted e-mail, it defaults the save location to where the XML was loaded.

    I've recently noticed that you can override how the save occurs in InfoPath using the OnSaveRequest function.

    However, I wanted to know the flexibility of it, when the form is not fully trusted.

    I want the form to start the saveDialogLocation from the My Documents, but am not sure what to type.
    I can't hard code the My Documents directory such as, XDocument.UI.SetSaveAsDialogLocation("C:\\USER Profile\My Documents"),
    for 2 reasons:
    1) I don't know what user is on.
    2) The My Documents changes if there is a network connection or not.

    I've noticed that if you write a directory that doesn't exists, such as XDocument.UI.SetSaveAsDialogLocation("z:\NotThere"), it automatically reroutes back to the My Documents, so I assume there should be a way to tell InfoPath to go to the My Documents, without placing a non-existant directory.

    If I don't place anything inside the quotes, such as XDocument.UI.SetSaveAsDialogLocation(""), it defaults the save location to the area where the xml was loaded.

    Is there a simple variable that I can use, that will always use the My Documents?
    eg: XDocument.UI.SetSaveAsDialogLocation("\\MyDocuments") ?

    As always,
    any help would be appreciated.

    - Reg
  • 10-12-2005 04:57 PM In reply to

    Re: Overriding the Default Save Location

    Hi Reg,
    Great question. I have no idea but I suspect that you may be able to get the USERPROFILE environment variable using System.Environment. USERPROFILE points to the My Documents folder. This will probably require special Environment permissions, though.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.