Saludos, estoy iniciandome en la programacion para sharepoint 2007 en C#,
necesito exportar a un archivo de texto el contenido de una lista de
sharepoint, la lista se llama "videos" y fue creada a partir de una
"descripcion" --multiples lineas de texto, tengo casi resuelto el problema
solo que no logro extraer los datos de la columna "descripcion" los demas
datos, de las columnas por default si puedo extraerlos, que me falta???
GRACIAS
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.SharePoint;
//using Microsoft.SharePoint.Utilities;
namespace DeletingEventHandler
{
public class DeletingAction : SPItemEventReceiver
{
public override void ItemDeleting(SPItemEventProperties properties)
{
using (SPWeb web = new
SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))
{
SPListItemCollection collItems =
web.Lists[properties.ListTitle].Items;
//
// Genera el archivo de videos.txt en el disco duro del
servidor
// Preparo el streaming del archivo
Stream stream = new FileStream(@"C:\videos.txt",
FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(stream);
//
//
SPList videosItemsList = web.Lists["videos"];
SPView videosItemsView =
videosItemsList.Views["vista_videos"];
SPListItemCollection videosItems =
videosItemsList.GetItems(videosItemsView);
foreach (SPListItem videoItem in videosItems)
{
string videoTitulo = getFieldValue(videoItem, "Name");
string videoID = getFieldValue(videoItem, "ID");
string videoDescripcion = getFieldValue(videoItem,
"Descripcion");
writer.WriteLine("&imagen=" + videoTitulo + ", id=" +
videoID + ", descripcion=" + videoDescripcion);
}
writer.Flush();
writer.Close();
stream.Dispose();
//
//
}
}
//
//
public static string getFieldValue(SPListItem listItem, string
fieldName)
{
string text = string.Empty;
if (fieldName == string.Empty)
{
return text;
}
try
{
object myObj = listItem[fieldName];
return ((myObj != null) ? myObj.ToString() : string.Empty);
//return ((myObj != null) ? myObj.ToString() : string.Empty);
}
catch
{
return string.Empty;
}
}
}
}
Leer las respuestas