又是上传文件问题,但绝对不同。远程上传文件失败!(源码奉上)
下面是我上传文件的一个函数:serverFilePath是上传到服务器的目录,clientPathFileName是客户端的完全文件名(包括目录)
protected void UpLoadFile(string serverFilePath, string clientPathFileName)
{
WebClient webClient = new WebClient();
if (!File.Exists(serverFilePath))
{
Directory.CreateDirectory(serverFilePath);
}
string[] arrCurrentFileName = ( string[] ) clientPathFileName.Split( '\\' );
string fileName = arrCurrentFileName[ arrCurrentFileName.GetUpperBound( 0 ) ];
webClient.UploadFile(serverFilePath + fileName ,clientPathFileName);
}
调试时是服务器与客户端是在同一计算机上,上传成功!!
但在另一台计算机,用IE运行我服务器上的程序,也上传同样的文件(大小一样),但总是提示:WebClient请求期间发生异常!
谁救我呀!