从这个优秀的作品,在这里的继: 批处理文件拷贝到SharePoint网站
我现在可以上传我的压缩文件有一个按钮的点击到SharePoint。
我现在的问题是这样的:我如何删除我上传使用同样的方法把文件?
我已经修改了代码稍有保存不同的文件,以不同的SharePoint文件夹。 示例如下:
Public Sub CopyToSharePoint()
暗淡XMLHTTP昏暗sharepointUrl昏暗sharepointFolder昏暗sharepointFileName昏暗LstrFileName,strFilePath,strMonthYear,PstrFullfileName,PstrTargetURL作为字符串昏暗LlFileLength只要昏暗Lvarbin()作为字节昏暗LvarBinData作为变暗淡FSO,LobjXML作为对象FSO设置=的CreateObject( “Scripting.FileSystemObject的” )昏暗FLDR作为文件夹昏暗˚F作为文件
“父的SharePoint sharepointUrl = “[SHAREPOINT PATH HERE]”
“设置月份%20Year strMonthYear =格式(现在(), “MMMM YYYY”)& “\”
“文件路径strFilePath = “[ARCHIVE DRIVE]” &strMonthYear
“检查是否为DRA当前月份%20年存在如果len(DIR(strFilePath,vbDirectory))= 0那么MKDIR “strFilePath” END IF
设置LobjXML =的CreateObject( “Microsoft.XMLHTTP”)
“当我们从上传设置FLDR = fso.GetFolder文件(strFilePath)
按照每个F在fldr.Files
如果格式(f.DateCreated, “日/月/年”)=格式(现在(), “日/月/年”)。然后
If InStr(1, f.Name, "[FILESTRING1]", vbTextCompare) > 0 Then sharepointFolder = "[SHAREPOINTSTRING1]/" ElseIf InStr(1, f.Name, "[FILESTRING2]", vbTextCompare) > 0 Then sharepointFolder = "[SHAREPOINTSTRING2]" ElseIf InStr(1, f.Name, "[DONOTUPLOADTHISFILE]", vbTextCompare) > 0 Then GoTo NextF: Else sharepointFolder = "[SHAREPOINTMAINFOLDER]" End If
sharepointFileName = sharepointUrl&sharepointFolder&f.Name
PstrFullfileName = strFilePath & f.Name LlFileLength = FileLen(PstrFullfileName) - 1 ' Read the file into a byte array. ReDim Lvarbin(LlFileLength) Open PstrFullfileName For Binary As #1 Get #1, , Lvarbin Close #1 ' Convert to variant to PUT. LvarBinData = Lvarbin PstrTargetURL = sharepointUrl & sharepointFolder & f.Name ' Put the data to the server, false means synchronous. LobjXML.Open "PUT", PstrTargetURL, False
“发送的文件中。LobjXML.Send LvarBinData
万一
NextF:接下来˚F
设置LobjXML =什么FSO设置=什么
结束小组