相关疑难解决方法(0)

无法建立连接,因为目标计算机主动拒绝它127.0.0.1:3446

我正在使用WCF4.0模板 - REST.我正在尝试创建一个使用流上传文件的方法.

问题总是发生在

Stream serverStream = request.GetRequestStream();
Run Code Online (Sandbox Code Playgroud)

流媒体类:

namespace LogicClass
{
    public class StreamClass : IStreamClass
    {
        public bool UploadFile(string filename, Stream fileStream)
        {
            try
            {
                FileStream fileToupload = new FileStream(filename, FileMode.Create);
                byte[] bytearray = new byte[10000];
                int bytesRead, totalBytesRead = 0;
                do
                {
                    bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
                    totalBytesRead += bytesRead;
                } while (bytesRead > 0);

                fileToupload.Write(bytearray, 0, bytearray.Length);
                fileToupload.Close();
                fileToupload.Dispose();
            }
            catch (Exception ex) { throw new Exception(ex.Message); }
            return true;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

REST项目:

[WebInvoke(UriTemplate …
Run Code Online (Sandbox Code Playgroud)

c# rest wcf httpwebrequest

67
推荐指数
2
解决办法
46万
查看次数

标签 统计

c# ×1

httpwebrequest ×1

rest ×1

wcf ×1