WPF中使用WebClient 向win7 上传文件
问题:WPF客户端程序使用webclient向服务器上(
操作系统是win7+iis 6)传图片(或者其他文件)时,出现后文的异常,文件就不能正常上传;但是在xp系统上是可以的,开始怀疑是虚拟目录没有写入权限,于是给了IIS_USER写入权限,但是还是不行,求问各位大神有没有遇到此类问题,如何解决呢?
代码:
/////////////////////////////////////
try
{
string serverFullPath = string.Format("{0}{1}", syscfg.ImageSavePathServer, curSnapImageName);
//string serverFullPath = string.Format("{0}{1}", syscfg.ImageSavePathServer, "test.jpg");
string clientFullPath = string.Format("{0}{1}", syscfg.ImageSavePath, curSnapImageName);
WebClient myWebClient = new WebClient();
myWebClient.Credentials = CredentialCache.DefaultCredentials;
FileStream fs = new FileStream(clientFullPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] postArray = br.ReadBytes(Convert.ToInt32(fs.Length));
Stream postStream = myWebClient.OpenWrite(serverFullPath, "PUT");
if (postStream.CanWrite)
{
postStream.Write(postArray, 0, postArray.Length);
}
else
{
throw new Exception("服务器端,没有写权限!");
}
// br.Close();
postStream.Close();//
一调用该方法就出现405异常 如下所示
//fs.Close();
// br.Close();
return string.E