I am looking for a way that I can rename the form for when it is being saved to the sharepoint document library using a textbox in the form as part of the filename. I also am looking at a way that I can open a text file where I would get the next number for my document number. I have attached the code to this message, which I am still having some issues getting with the code. I want to make sure that the code is right and that the file location works in the code. I am using Visual Studio 2008 Full Version to create the InfoPath Form and C# coding behind it. Any help would be appreciated.
public void FormEvents_Save(object sender, SaveEventArgs e)
{
// Write your code that will run before a Save or Save As operation here.e.Filename = MainDataSource.CreateNavigator().SelectSingleNode("my:myFields/my:RecallNo").Value;
// The Dirty property will be set to false if save is successful.
e.PerformSaveOperation();
// Write your code that will run after saving here.e.CancelableArgs.Cancel = false;
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
string fileContents;using (StreamReader sr = new StreamReader(@"TextFile1.txt"))
{
fileContents = sr.ReadToEnd();
MainDataSource.CreateNavigator().SelectSingleNode("my:myFields/my:RecallNo") = fileContents;
}
using (StreamWriter sw = new StreamWriter(@"TextFile1.txt", true))
{
fileContents = fileContents + 1;
sw.WriteLine(fileContents);
}
}