本文介绍了Webservice -FileUpload和FileDownload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...如何使用webservices上传文件和下载文件.... i我是写webservices的新手...我有些主意...请指导我...
我的输入是文本文件
我的输出是fileid,成功消息,错误消息

hi...how to do file upload and file download using webservices .....i am fresher for writing the webservices ...i got some idea...Please guide me...
my input is text file
my output is fileid ,success message,error message

public string UPLOADINGFILES(string F_NAME,binary Content, out int SUCCESS)
    {
        DbCommand objFileHandler = null;
        string strtempfile = string.Empty;
        try
        {
            objConn = dbFileServices.CreateConnection();
            if (objConn.State == ConnectionState.Closed)
            {
                objConn.Open();
            }
            objFileHandler = objConn.CreateCommand();
            strtempfile = "USP_FILE_UPLOAD";
            objFileHandler.CommandType = CommandType.StoredProcedure;
            objFileHandler = dbFileServices.GetStoredProcCommand(strtempfile);


         
            file_id = ((string.IsNullOrEmpty(file_id) ? string.Empty : file_id.Trim()));
            F_NAME = ((string.IsNullOrEmpty(F_NAME) ? string.Empty : F_NAME.Trim()));
            Content = ((string.IsNullOrEmpty(Content) ? string.Empty : Content.Trim()));
            

            dbFileServices.AddInParameter(objFileHandler, "@FILEID", DbType.String, file_id.Trim());
            dbFileServices.AddInParameter(objFileHandler, "@F_NAME", DbType.String, F_NAME.Trim());
            dbFileServices.AddInParameter(objFileHandler, "@CONTENT", DbType.String, Content.Trim());

            dbFileServices.AddOutParameter(objFileHandler, "@SUCCESS_PARAMETER", DbType.String, 20);
            //dbFileServices.AddOutParameter(objFileHandler, "@ERRORDESC", DbType.String, 2000);


            SUCCESS = Convert.ToInt32(objFileHandler.Parameters["@SUCCESS_PARAMETER"].Value);
            file_id = Convert.ToString(objFileHandler.Parameters["@FILE_ID"].Value);
            //_strRetMes = (objFileHandler.Parameters["@ERROR_DESC"].Value).ToString().Trim();



        }
        catch (Exception ex)
        {
            throw ex;
        }
    }




我不知道如何使用varbinary .........指导我




i dont know how to use the varbinary .........guide me

推荐答案

public string UPLOADINGFILES(string F_NAME,byte[] Content, out int SUCCESS)


并在您的参数中使用


and in your parameters use

dbFileServices.AddInParameter("@CONTENT", DbType.Binary, Content);


这篇关于Webservice -FileUpload和FileDownload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 20:36