Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The following solution is provided from: <a href="http://www.codeproject.com/KB/sharepoint/File_Shunter.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/sharepoint/File_Shunter.aspx</a></p> <p>Note however, as mentioned in the other answer, the INTERNAL name of the field IS required.</p> <p><strong>Web.Config Keys</strong></p> <p>If you choose to, with the following added to the Web.config for your application (for this example only, alternatively you could simply include the required values [Server, Document Library, User, Domain, Password, etc.] in your code):</p> <pre><code>&lt;configuration&gt; &lt;appSettings&gt; &lt;add key="SharePointServer" value=http://SP Portal/Site/&gt; &lt;add key="DocLibrary" value="Doclib"/&gt; &lt;add key="User" value="User"/&gt; &lt;add key="Domain" value="Domain"/&gt; &lt;add key="Pwd" value="Pwd"/&gt; &lt;add key="GlobalSharedPath" value="D:\"/&gt; &lt;/appSettings&gt; </code></pre> <p><strong>Code:</strong></p> <pre><code>Public Function WSSUpdateFile(ByVal sFileName As String, ByVal sSiteDoc As String, ByVal sTestCol As String) As String Dim sUser As String = ConfigurationManager.AppSettings("User") Dim sPwd As String = ConfigurationManager.AppSettings("Pwd") Dim sDomain As String = ConfigurationManager.AppSettings("Domain") Dim sFileIDinList As String Dim strBatch As String = "" sSiteDoc = Replace(sSiteDoc, "%20", " ") sSiteDoc = Replace(sSiteDoc, "\", "/") Dim sFinalFilePath As String Dim sSPURL As String = ConfigurationManager.AppSettings("SharePointServer") Dim sDocLib As String = ConfigurationManager.AppSettings("DocLibrary") Try Dim netAccess As System.Net.NetworkCredential = New System.Net.NetworkCredential(sUser, sPwd, sDomain) Dim listService As New SPLists.Lists listService.Url = sSPURL &amp; "/_vti_bin/lists.asmx" listService.Credentials = netAccess sFileIDinList = sGetID(listService.Url, sDocLib, sFileName) If sFileIDinList &lt;&gt; "" Then sFinalFilePath = sSPURL &amp; "/" &amp; sDocLib &amp; "/" &amp; sFileName 'Now we have FileID so update the list strBatch = "&lt;Method ID='1' Cmd='Update'&gt;" + _ "&lt;Field Name = 'ID'&gt;" &amp; sFileIDinList &amp; "&lt;/Field&gt;" + _ "&lt;Field Name = 'FileRef'&gt;" &amp; sFinalFilePath &amp; "&lt;/Field&gt;" + _ "&lt;Field Name = 'TestCol'&gt;" &amp; sTestCol &amp; "&lt;/Field&gt;" + _ "&lt;/Method&gt;" Dim xmlDoc = New System.Xml.XmlDocument Dim elBatch As System.Xml.XmlElement = xmlDoc.createelement("Batch") elBatch.InnerXml = strBatch Dim ndreturn As System.Xml.XmlNode = listService.UpdateListItems(sDocLib, elBatch) End If Return "TRUE" Catch ex As Exception Return ex.Message End Try End Function Private Function sGetID(ByVal sURL As String, ByVal sListGUID As String, ByVal sFileName As String) As String Dim sUser As String = ConfigurationManager.AppSettings("User") Dim sPwd As String = ConfigurationManager.AppSettings("Pwd") Dim sDomain As String = ConfigurationManager.AppSettings("Domain") Dim netAccess As System.Net.NetworkCredential = New System.Net.NetworkCredential(sUser, sPwd, sDomain) Dim L As New SPLists.Lists L.Credentials = netAccess L.Url = sURL Dim xmldoc As XmlDocument = New XmlDocument Dim query As XmlNode = xmldoc.CreateNode(XmlNodeType.Element, "Query", "") query.InnerXml = "&lt;OrderBy&gt;&lt;FieldRef Name='Modified' Ascending='False'&gt;&lt;/FieldRef&gt;&lt;/OrderBy&gt;""" Try Dim caml As XmlNode = L.GetListItems(sListGUID, Nothing, query, Nothing, "1", Nothing) Dim id As String = caml.ChildNodes(1).ChildNodes(1).Attributes("ows_ID").Value Return id Catch ex As Exception Return ex.Message End Try End Function </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload