从共享点库中打开文件进行编辑

编程入门 行业动态 更新时间:2024-10-26 00:28:12
本文介绍了从共享点库中打开文件进行编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好! 我在编辑sharpoint文档库中的现有XML文件时遇到问题.. 我要做的是搜索一个xml文件(基于其namem),并在找到该文件时将其加载到XmlDocument中,以便可以对其进行编辑... 这是到目前为止我得到的...运行此代码时,找到了我正在搜索的文件/项目(让我说是test.xml),但是问题是我不知道如何将其加载到xml文档中进行编辑. ..还是我做错了这个方法? :P 谢谢您的回答...

Hello! I ran into a problem editing an existing XML file in a sharpoint documents library.. What I want to do is search for an xml file(based on its namem), and when its found, load it into an XmlDocument so it can be edited... this is what I got so far... When I run this code, the file/item Im searching for is found(lets say test.xml), but the problem is I dont know how to load it into the xmldocument for editing...Or am I doing this the wrong way? :P Thank you for your answers...

public XmlDocument GetXMLDocument(string name) { XmlDocument document = new XmlDocument(); SPListItemCollection items = GetList(libraryName).Items;//gets the list foreach (SPItem item in items) { if (item.Name == name) document.Load(item); //I get lost here :) } return document; }

推荐答案

好,所以我想我找到了一个解决方案,不知道它是否是最好的,但是现在它符合我们的目的……这是做什么的直截了当. 我将文件打开,因为将二进制数组加载到流中,因此可以在xmldocument.load方法中使用它,如果有更好的方法,请告诉我:) Ok so I think I found a solution, dont know if its the best but for now it servs our purpose... What this does is preaty straight forward. I open the file as a binary array wich is loaded into a stream so it can be used in xmldocument.load method, to be procesed... If there is a better way of doing it, please tell me :) public XmlDocument GetXMLDocument(string name) { XmlDocument document = new XmlDocument(); SPWeb site = GetSite(); string fileUrl = _url + libraryname + "/" + name; SPFile temp = site.GetFile(fileUrl); byte[] table = temp.OpenBinary(); MemoryStream stream = new MemoryStream(table); document.Load(stream); //clear resources stream.Dispose(); return document; }

更多推荐

从共享点库中打开文件进行编辑

本文发布于:2023-11-06 06:20:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:库中   编辑   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!