Hi Benjamin,
Ah - now I have a better understanding. When you call the "Save" method,
this is used when the form has been previously saved - as such, the first
time you call this method it will fail.
As you are using .NET, there are a couple of options:
- Display a .NET Save Dialog to allow the user to save the form
- Use a "try/catch" statement and if the save fails, drop to the "SaveAs"
method and hard-code the location
Let me know if this helps!
Scott L. Heim
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
Benjamin Wegner - 05 Sep 2005 09:46 GMT
Hi Scott,
I am using the following code. It's nearly the same you suggested.
Regards,
Benjamin
if( thisXDocument.IsNew )
{
if( thisXDocument.Solution.URI.LastIndexOf("Forms/") > 0 )
{
string url = thisXDocument.Solution.URI.Substring(0,
thisXDocument.Solution.URI.LastIndexOf("Forms/"));
thisXDocument.SaveAs(url + this.GetFileName() + ".xml");
}
else
{
string url = thisXDocument.Solution.URI.Substring(0,
thisXDocument.Solution.URI.LastIndexOf("\\"));
thisXDocument.SaveAs(url + "\\" + this.GetFileName() + ".xml");
}
}
else
{
thisXDocument.UI.SetSaveAsDialogFileName(this.GetFileName());
thisXDocument.Save();
}