遞迴上傳檔案和資料夾至SharePoint

2021-09-06 01:12:09 字數 1269 閱讀 9818

如果你使用sharepoint 2010的話,可以直接「上傳多個檔案」。在彈出的對話方塊中可以直接往裡拖放整個資料夾。如下圖所示:

如果是sharepoint 2007的話,可以通過「資源管理器」檢視,像在資源管理器裡管理本地檔案一樣,拖放資料夾。

下面介紹的方式是下策。當然下下策就是你手工乙個乙個的建資料夾上傳檔案了。下策是你可以通過sharepoint物件模型或web services的方式編寫乙個遞迴程式來實現從本地資料夾到sharepoint庫的上傳工作。這裡我們演示的是通過物件模型上傳到乙個sharepoint 2010站點。**對於sharepoint 2007站點也是可用的。唯一的區別就是32位和64位,相應的.net framework版本和microsoft.sharepoint.dll版本。

引用microsoft.sharepoint.dll以便訪問sharepoint物件模型。

try

}catch (exception ex)

createdirectories方法是乙個遞迴方法,接收兩個引數。path引數指定本地計算機檔案系統中的源位置;ofoldercollection引數指定目標資料夾集合。spfoldercollection的用法參考這裡。

private void createdirectories(string path, spfoldercollection ofoldercollection)

//上傳多個資料夾

參考資料

uploading files and folders recursively to a sharepoint site

Qt遞迴遍歷檔案和資料夾

遞迴遍歷資料夾,找到所有的檔案 filepath 要遍歷的資料夾的檔名 int findfile const qstring filepath 取到所有的檔案和檔名,但是去掉.和.的資料夾 這是qt預設有的 dir.setfilter qdir dirs qdir files qdir nodota...

檔案和資料夾重新命名 遞迴思想

方法 資料夾 directory.move strfullname,strupfullname doccount.tostring 方法 檔案fi.moveto path.combine dir.fullname,i.tostring this.textboxstring.text.trim fi....

Linux下遞迴遍歷檔案和資料夾

include include include include include include include 利用深度優先遍歷實現檔案檢索 void dfs const char filedir if dirstat.st mode s ifdir else int main int argc,c...