How to retrive Save As file path?

L

leslie.mcgann

When the user saves an InfoPath form, I need to trigger some logic
that will create another file based on the file name typed by the user
in the Save As dialog. Although MSDN suggests that I should be able
to retrieve the file name from the SaveEventArgs.Filename property,
this is not the case. If the operation is Save As, the Filename
property is empty even after PerformSaveOperation is called.

Here is some sample code:

public void FormEvents_Save(object sender, SaveEventArgs e)
{
// Write your code that will run before a Save or Save As
operation here.

// The Dirty property will be set to false if save is successful.

e.PerformSaveOperation();
String s = e.Filename;

// Write your code that will run after saving here.

e.CancelableArgs.Cancel = false;
}

In this example, the string s is empty if the operation is Save As.
It is populated only when the operation is Save. MSDN says the
following about the SaveEventArgs.Filename property:

If the IsSaveAs property of the SaveEventArgs object is true, and a
save operation has not yet occurred, the FileName property returns an
empty string. If the IsSaveAs property is true and a save operation
has already occurred, the value returned by the FileName property is
the file name under which the form was saved.

So, Filename should be getting populated with the name the user typed,
but it isn't. What gives? Has anyone else encountered this problem
and found a good workaround?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top