OnSave Rename the file using a field in form - InfoPath Dev
in

InfoPath Dev

OnSave Rename the file using a field in form

Last post 02-03-2009 09:08 AM by Ejuozaitis. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 02-03-2009 09:08 AM

    OnSave Rename the file using a field in form

    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);

    }

    }

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.