我的程序获取列表共享点的版本历史元素的数据并将数据放入 txt
文件中。输出“名称”列表项和“位置”。一切正常,但不幸的是输出“名称”非常糟糕。在我看来这一行的问题
string strFirstName = Convert.ToString(objVersion["Name"]);
输出不良:
Name 4049;#Zabiyakin Makar ,#STALT\Zabiyakin,# Zabiyakin@stalt.ru,#,#Zabiyakin Makar Location В Name 4049;#Zabiyakin Makar ,#STALT\Zabiyakin,# Zabiyakin@stalt.ru,#,#Zabiyakin Makar位置 首页
我想要输出:
名称 Zabiyakin Makar 位置 В 名称 Zabiyakin Makar 位置 首页
代码程序:
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.IO;
namespace ControlTest.Layouts.ControlTest
{
public partial class ApplicationPage1 : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
//string ListUrl = "/Deps/sup/Lists/Whereabouts";
SPList objList = SPContext.Current.Web.Lists["Whereabouts"];
SPQuery objQuery = new SPQuery();
objQuery.Query = "<Where><Gt><FieldRef Name=\"ID\"/><Value
Type=\"Counter\">0 </Value></Gt></Where>";
SPListItemCollection objItemColl = objList.GetItems(objQuery);
foreach (SPListItem objItem in objItemColl)
{
SPListItemVersionCollection objVerisionColl = objItem.Versions;
if (objVerisionColl.Count > 1)
{
foreach (SPListItemVersion objVersion in objVerisionColl)
{
int versionID = objVersion.VersionId;
DateTime timeofcreation = objVersion.Created;
string strVersionLabel = objVersion.VersionLabel;
SPListItem objLstItm = objVersion.ListItem;
string strFirstName = Convert.ToString(objVersion["Name"]);
//string strFirstName =
((SPFieldUserValue)objVersion["Name"]).User.Name;
string strPlace = Convert.ToString(objVersion["location"]);
System.IO.TextWriter writer = new
StreamWriter(@"C:\custommenuoutput.txt", true);
writer.WriteLine(string.Format("Name: {0} location: {1}",
strFirstName, strPlace));
writer.Close();
}
}
}
}
}
}
如何做出好的输出?请帮我 !