當前位置:首頁 » 文件管理 » sharepoint上傳文件

sharepoint上傳文件

發布時間: 2023-01-02 07:53:38

1. SharePoint上傳文件失敗

目的端有相同文件吧,並且這個文件被checkout了,你可能許可權不夠,看不到目的端的文件,隨便換一個文件上傳試試,應該就可以;然後等那個文件check in後再說

2. sharepoint文檔保存在本地,但不能上傳至伺服器

sharepoint文檔保存在本地,不能上傳至伺服器的原因:
1、文件不符合伺服器接收的類型、內容不合法。
2、文件大小超出了單個文件的限制大小。
3、伺服器當時服務異常,待服務正常運行時可以上傳。
4、網路異常,導致傳輸異常。

3. 如何使用WebService上傳文件至SharePoint 文檔庫中

問題描述: 通過WebService的形式將文件上傳至SharePoint的文檔庫,我認為有2個難點,其中比較好解決的是文件傳輸,這個文件傳輸有好多種辦法,比如使用ftp協議.最難的一個可能就是許可權問題.(原來我的解決方法是正確的,只是模擬用戶的時候域名寫的不對,哈哈,)
我想會有好多人也會遇到這個問題,我的這個解決方法,在一定程度上可以解決一些問題.(^_^),關於身份模擬請參考msdn中的描述。此程序片段不包含目錄驗證的代碼.
這個問題困擾了我好久.我曾經嘗試過多種方法.但一樣的程序,在windows應用程序里運行就ok,一放到webservice里就出問題了.(不過今天晚上又測試了多次,證明我的方法是有效的,興奮中....)
以下是通過文件監控的方式實現的文件上傳程序代碼:(裡面採用了模擬windows用戶的方式模擬當前的操作用戶)
private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
{
Application.DoEvents();
WindowsImpersonationContext wic = null;
if( wic != null ) wic.Undo();
try
{
System.IO.File.Copy(e.FullPath,"c://AresTemp//"+e.Name,true);
FileStream fStream;
fStream= File.OpenRead("c://AresTemp//"+e.Name);
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
if(File.Exists("c://AresTemp//"+e.Name)==true)
{
File.Delete("c://AresTemp//"+e.Name);
}

wic =SPUtil.GetWindowsIdentity();
SPWeb myweb=new SPSite(SharePointURL).OpenWeb();
myweb.AllowUnsafeUpdates=true;

myweb.Files.Add(SharePointURL+"/"+e.Name,contents,true);
// if (File.Exists(e.FullPath))
// File.Delete(e.FullPath);
if( wic != null ) wic.Undo();
AresLog.recordLog("文件上傳成功","","",e.Name ,e.FullPath);

}
catch(Exception ee)
{
if( wic != null ) wic.Undo();
AresLog.recordLog("上傳文件異常","","",ee.Message,ee.StackTrace);
}
}
以下是我寫的通過ftp的方式,將文件傳輸到本地,然後讀取本地磁碟文件,上傳到sharpoint文檔庫的代碼:(需要注意域名的書寫,此代碼已經過本機測試成功,但具體環境不同,也可能造成一定的差異)
[WebMethod]
public string UpLoadFilesToSPS(string FtpServer,string FtpUser,string FtpPwd,string FtpPath,string FilesName,string FilesInfo,string targetUrl)
{
//ftp settings
FtpClient myFTP=new FtpClient();
myFTP.Server=FtpServer;
myFTP.Username=FtpUser;
myFTP.Password=FtpPwd;
myFTP.RemotePath=FtpPath;
//filePath,info
string[] fName=Microsoft.VisualBasic.Strings.Split(FilesName,";",-1,Microsoft.VisualBasic.CompareMethod.Text);
string[] fInfo=Microsoft.VisualBasic.Strings.Split(FilesInfo,";",-1,Microsoft.VisualBasic.CompareMethod.Text);
int i=0;
//檢查和創建本地環境
if(Directory.Exists("C://AresTemp")==false)
{
Directory.CreateDirectory("C://AresTemp");
}
foreach(string fDirectory in fInfo)
{
if(Directory.Exists("C://AresTemp//"+fDirectory)==false)
{
Directory.CreateDirectory("C://AresTemp//"+fDirectory);
}
}
//文件下載
for(i=0;i<fName.Length;i++)
{
myFTP.DownloadEx(fName[i],"C://AresTemp//"+fInfo[i]+"//"+fName[i],true);
}
myFTP.Close();
WindowsImpersonationContext wic = null;

if( wic != null ) wic.Undo();
//獲取模擬用戶信息
ZSoft.WindowsImpersonation.WIUser myUser=new ZSoft.WindowsImpersonation.WIUser(ServerUser,ServerName,ServerPassword);
myUser.impersonateValidUser();
wic =myUser.wic;
SPWeb myweb=new SPSite(targetUrl).OpenWeb();
myweb.AllowUnsafeUpdates=true;
for(i=0;i<fName.Length;i++)
{
FileStream fStream;
fStream= File.OpenRead("c://AresTemp//"+fInfo[i]+"//"+fName[i]);
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
myweb.Files.Add(targetUrl+"/"+fInfo[i]+"//"+fName[i],contents,true);
}
myweb.Close();
if( wic != null ) wic.Undo();
return "文件傳輸成功!";
}

熱點內容
android合並圖片 發布:2025-08-26 18:23:25 瀏覽:486
19款的s哪個配置性價比最高 發布:2025-08-26 18:14:46 瀏覽:703
錄音機錄音文件夾 發布:2025-08-26 18:06:01 瀏覽:301
伺服器如何選購前言 發布:2025-08-26 18:01:57 瀏覽:469
如何知道自己小米手機熱點密碼 發布:2025-08-26 17:35:06 瀏覽:917
編程工具化 發布:2025-08-26 17:31:39 瀏覽:856
刀片伺服器搭建私有雲 發布:2025-08-26 17:29:25 瀏覽:805
演算法設計與分析習題答案 發布:2025-08-26 16:41:06 瀏覽:634
車載中控安卓機如何安裝u盤聽歌 發布:2025-08-26 16:36:04 瀏覽:43
解壓密碼漢字 發布:2025-08-26 16:34:56 瀏覽:723