zoukankan      html  css  js  c++  java
  • 在使用SPS操作文件的时候碰到这样的问题

      我在使用SPS操作文件(删除)的时候碰到这样的问题,使用如下代码删除站点根目录的文件时会出问题,而删除站点子目录下的文件时不会;上传文件到站点根目录也会出问题,而上传到子目录则不会  :
    name space MMXSPS
    {
        class SPSAccess
        {

        ........   

          /// <summary>
            /// 删除在指定文件夹的指定文件
            /// </summary>
            /// <param name="strSiteName">文件所在的站点:siteName----例:"/Sites/SiteName"</param>
            /// <param name="strFolder">文件所在的文件夹 :folderName----例:"/Sites/SiteName/FolerPath</param>
            /// <param name="strFileName">文件名 :filename.htm</param>
            public bool DeleteFile(string strSiteName,string strFolder,string strFileName)
            {
                string strServerURL=this.SPServerURL;
                try
                {

                    strSiteName=strSiteName;
                    SPWeb Myweb=new SPSite(strServerURL).AllWebs[strSiteName];
                    Myweb.AllowUnsafeUpdates=true;
                    string strNewUrl1;
                    if (Myweb.GetFolder(strFolder).Exists)
                    {
                        SPFileCollection delFiles = Myweb.GetFolder(strFolder).Files;
                        strNewUrl1=strServerURL + strFolderPath + "/" + strFileSaveToName;
                        if(site.GetFile(strNewUrl1).Exists) //会出错
                            delFiles.Delete(strFolder+"/"+strFileName);
                      }
                    return true;
                }
                catch(Exception msg)
                {
                    this._ErrorMessage=msg.Message.ToString();
                    return false;
                }
            }
        .......
            public string Upload(string strSiteName,string strFolder,string strFileName)
            {
                SPFileCollection spfc;
                ......
                strNewUrl1=strServerURL + strFolderPath + "/" + strFileSaveToName;
                upFile = spfc.Add(strNewUrl1, ConvertToStream(InputFileStream));//会出错
                ......
            }
        .......

            public byte[] ConvertToStream(Stream fStream)
            {
                ....
            }

        }

    }

    也不知道为什么会这样???

  • 相关阅读:
    WCF – System.ServiceModel.FaultException
    SSB – Connection handshake failed
    JQuery语法总结和注意事项
    删除指定目录及其子目录和文件
    Windows 7中还不能通过“HyperV管理器”连接HyperV Server 2008 R2服务器解决
    tomcat虚拟目录映射网络共享目录的问题
    Creating a Virtual Directory with a UNC Path (IIS 6.0)
    百度地图api根据地区名称反查其经纬度的实例
    远程管理server core上的hyperv
    ios5中使用Reachability的问题
  • 原文地址:https://www.cnblogs.com/llbofchina/p/219145.html
Copyright © 2011-2022 走看看