I have a default team site and want to create a new text file in it's document library programmatically.
SPList srcList = srcWeb.Lists["Documents"]
Returns a valid list. I can loop the listItems here,
foreach (SPListItem item in srcList.Items)
Get the File for each item and even the contents of each file.
However, even though I can get existing files, I cannot seem to create a new file in this list.
What I tried:
srcWeb.Folders["Documents"] - returns null
SPListItem destLI = srcWeb.Lists["Documents"].Items.Add(); - gives me a valid list item with a NULL .File. (Which I cannot initialize, since SPFile does not contructor).
srcWeb.Lists["Documents"].Folders.Add - I DO NOT want to create a new folder but simply add files to the root directory of the list.
POST technique (http://msdn.microsoft.com/en-us/library/ms454491(v=office.14).aspx) I'd rather avoid this because I will add Metadata in the future.
Any ideas?