none
Programming SharePoint Document Libraries Event Receiver

    Pertanyaan

  • hello !

     how to add  newcreated item of list in file.txt on the library  ?

     this simple code,which  add  newcreated item of list in another list

     if (properties.ListTitle == "test")
                   {
                       string MyTemp = properties.AfterProperties["Title"].ToString();//jhgf 
                           
                       
                           SPSite MySite = new SPSite("http://Localhost/Deps/sup");
                           SPWeb web = MySite.OpenWeb();
                           SPList list = web.Lists["test2"];
                           SPItem item = list.Items.Add();
                           item["Title"] = properties.ListItem["Title"];
                           item.Update();
    }

     What about an analog code to the file library ?

     give me , please, link, example, somethink.

    thanks!!

    11 Juli 2012 8:52

Semua Balasan

  • Hi,

    Simple C# code will help you here to write text in file. Check the below MSDN article for more information.:

    http://msdn.microsoft.com/en-us/library/8bh11f1k.aspx

    Hope it could help


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    11 Juli 2012 9:01
    Moderator
  • ox) thanks. this link is not help.

    before this topic i do it use ApplicationPage.aspx

                              1 step)i write data of item  list in file.txt on the server

                              2 step) i upload this file.txt in the library.

    this bad way.

    i want without server. 

    automaticaly, by eventreceiver  item.add() in file.txt of library sharepoint.

    is it possible?

    thanks

    11 Juli 2012 12:39
  • >by eventreceiver  item.add() in file.txt of library sharepoint.

    Yes you can do it through event receiver as well. You need to use ItemAdded event and find the text file in document library where you want to add text. The above link will help you to write text in file only. You can follow below steps

    1. Find out text file from document library

    2. Write text in file and save it back to library

    Here is very useful link to update library document programmatically

    http://howtosharepoint.blogspot.in/2010/05/programmatically-edit-and-save-file.html

    I know it is not exact solution what you are looking for but you are very close to it.


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    12 Juli 2012 5:18
    Moderator