webservice 文件流传入服务器

   [WebMethod(Description = "app考核评审附件上传    多个文件之间以'|'分隔     strDocCode取值:OState<4 strDocCode='MyP' else OState>=4  strDocCode='MyA' ", EnableSession = true)]
    public string appAuditUpfile(string strStaffNo, string strOID, string strDocCode, string strFileName, string strFile, string strFileSize, string strFileMemo)
    {
        var strJson = "";
        if (strFile.Length > 0)
        {
            string[] strTemp = strFile.Split('|');
            string[] strTempName = strFileName.Split('|');
            string[] strTempSize = strFileSize.Split('|');
            string[] strTempMemo = strFileMemo.Split('|');
            int strLength = strTemp.Length;
            if (strTemp.Length > 0)
            {
                for (int i = 0; i < strTemp.Length; i++)
                {
                    int seqno = int.Parse(GetAuditFileSeqno(strOID, strDocCode));
                    string strPath1 = "UpFile\Assess\";
                    var strExtent = strTempName[i].Substring(strTempName[i].LastIndexOf(".") + 1);
                    var strConvert = strOID + seqno + "." + strExtent;
                    string strPath = strTempName[i] + strConvert;
                    string strFilePath = Server.MapPath("UpFile\Assess\") + strPath;
                    string strDiskFolder = System.Web.HttpContext.Current.Server.MapPath(strPath1);
                    strPath = "../UpFile/Assess/" + strTempName[i] + strConvert;
                    if (!Directory.Exists(strDiskFolder))
                    {
                        Directory.CreateDirectory(strDiskFolder);
                    }
                    Base64Decoder decoder = new Base64Decoder();
                    Convert.FromBase64String(strTemp[i]);
                    byte[] buffer = decoder.GetDecoded(strTemp[i]);
                    FileStream fs = new FileStream(strFilePath, FileMode.Create);
                    BinaryWriter bw = new BinaryWriter(fs);
                    if (strTemp[i] != "" && System.IO.File.Exists(strFilePath))
                    {
                        bw.Write(Convert.FromBase64String(strTemp[i]));
                    }
                    bw.Close();
                    fs.Close();
                    SqlParameter[] pamFile = {
                                         new SqlParameter("@chrStaffNo",SqlDbType.Char,5,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,strStaffNo),
                                         new  SqlParameter("@chrDocNo",SqlDbType.VarChar,50,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,strOID),
                                         new  SqlParameter("@chrDocCode",SqlDbType.VarChar,3,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,strDocCode),
                                         new  SqlParameter("@varFilePath",SqlDbType.VarChar,100,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,strPath),
                                         new  SqlParameter("@varFileName",SqlDbType.VarChar,200,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,strTempName[i]),
                                         new  SqlParameter("@intFileSize",SqlDbType.Int,4,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,Convert.ToInt32(strTempSize[i])),
                                         new  SqlParameter("@varFileMemo",SqlDbType.VarChar,500,ParameterDirection.Input,true,0,0,null,DataRowVersion.Current,strTempMemo[i])
                                     };
                    bool blnFlag = new AccessDB().ExecuteProcedure("frmAddUserFormClip", pamFile);
                    if (!blnFlag)
                    {
                        strJson = "{"respMessage"" + ":" + ""添加附件" + strTempName[i] + "时操作失败!"}";
                    }
                    else
                    {
                        strJson = "{"respMessage"" + ":" + ""保存成功"}";
                    }
                }
            }
        }
        return strJson;
    }
原文地址:https://www.cnblogs.com/ljj4490/p/7272306.html