System.IO.IOException: 指定的服务器无法在 Web Form

问题描述

我当前的项目有问题,是关于将文件上传到共享文件夹,我在 localhost 中尝试并成功,但是在将其部署到服务器中的 IIS 后,它失败了,我只是收到一个错误像这样的消息:

enter image description here

我该如何解决这个问题?

这是我当前的代码

if (file1.HasFile)
{
bool exists = System.IO.Directory.Exists(Url +"/"+ emp_id);
if (!exists)
{
System.IO.Directory.CreateDirectory(Url + "/"+ emp_id);
}
file1.SaveAs(Server.MapPath("TemporaryFile/" + filename + ext));
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp:"+IPUrl);
ftp.Credentials = new NetworkCredential(UserName1,Password1);
ftp.KeepAlive = true;
ftp.UseBinary = true;

FtpWebRequest ftp2 = (FtpWebRequest)FtpWebRequest.Create("ftp:"+Url+"/" +emp_id+"/"+ filename + ext);
ftp2.Credentials = new NetworkCredential(UserName,Password );
ftp2.KeepAlive = true;
ftp2.Method = WebRequestMethods.Ftp.UploadFile;
Stream stream = ftp2.GetRequestStream();
string FilePath = System.IO.Path.GetFileName(file1.PostedFile.FileName);
FileStream file = File.OpenRead(Server.MapPath("TemporaryFile/" + filename + ext));

int length = 1024;
byte[] bytebuff = new byte[length];
int bytesRead = 0;

do
{
bytesRead = file.Read(bytebuff,length);
stream.Write(bytebuff,bytesRead);
}
while (bytesRead != 0);

file.Close();
stream.Close();
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...