good news / bad news ............. using code based on the .pdf in my previous reply, I could SaveAs.
PROBLEM: it's a temporary file in my temp directory.
I tried to rename the temporary file with very unhappy results:
// Save the form
string tempFileName = System.IO.Path.GetTempFileName() + ".xml";
this.SaveAs(tempFileName); // ~~ do not know why ... we need temp file name first ?????
//============= can not rename ================
File.Move(tempFileName, newFileSaveAsFilename); // ~~~~~~~~~~~~~~~~~~~~~~~rename the file to reflect the student and the course.
// System.IO.IOException was unhandled by user code
// Message="The process cannot access the file because it is being used by another process."
// Source="mscorlib"
// StackTrace:
// at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
// at System.IO.__Error.WinIOError()
// at System.IO.File.Move(String sourceFileName, String destFileName)
// at StudentProgressReport.FormCode.lessonEnd_Clicked(Object sender, ClickedEventArgs e) in C:\Drivers\driverManagement\infoPathManagedCode\StudentProgressReport2\FormCode.cs:line 735
// at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
// at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Please note: in my case, I have removed the ability for the form user to manually Save/SaveAs ...
this is because I need full control over the final file names and can not allow end users to make filename typos.
???? is it just me, or is the InfoPath 2007 documentation substantially incomplete with regards to crafting managed code?
I wish Ken Getz et al would do for InfoPath 2007 what they did with there fine series of books for MS Access.
Regards,
Gerry (Lowry)
Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 ·
[email protected]