小菜来袭
2017-01-06 03:45c# 调用webserver上传文件时候 出现的问题
客户端代码
WebReference.WebService1 webserver = new WebReference.WebService1();
string path = txtPath.Text.Trim();//本地路径
byte[] bytes = GetBytesByPath(path);//获取文件byte[]
string uploadPath = comdirectory.Text;//上传服务器文件夹路径
webserver.UploadFile(bytes, uploadPath, FileName);
webserver 上的
public bool UploadFile(byte[] fs, string path, string fileName)
{
bool flag = false;
try
{
path = Server.MapPath(path);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
//定义并实例化一个内存流,以存放提交上来的字节数组。
MemoryStream m = new MemoryStream(fs);
//定义实际文件对象,保存上载的文件。
FileStream f = new FileStream(path + "\\" + fileName, FileMode.Create);
//把内内存里的数据写入物理文件
m.WriteTo(f);
m.Close();
f.Close();
f = null;
m = null;
flag = true;
}
catch (Exception ex)
{
flag = false;
}
return flag;
}
这里上传大点的文件(3M以上)就会报错 Not Found。和 最大请求长度超过了 如何
解决这个问题呢?
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- .net 调用金蝶k3webservice问题
- 开发语言
- visual studio
- microsoft
- asp.net
- c#
- 2个回答
- C#中的SoapHeader身份验证(cleverelements)
- authentication
- soap
- php
- c#
- web-services
- 2个回答
- 如何在wpf应用程序中使用json响应
- json
- wpf
- php
- c#
- 2个回答
- C# 获取sql内容,生成xml文件,并且以webservice形式发送
- sql
- xml
- c#
- 4个回答
- C# 调用webservice是怎么添加Gzip
- gzip
- web service
- c#
- 2个回答
换一换