我有一个使用 asp.net 的网站。我想知道如何使用 fileUpload.thanks 通过 IP 地址将文件从我的机器上传到其他机器
html
<form id="form1" runat="server" enctype="multipart/form-data">
<asp:FileUpload ID="FileUpload1" runat="server" ToolTip="Select Only Excel File" />
<asp:Button runat="server" ID="btnUpload" OnClick="btnUploadClick" Text="Upload" />
</form>
代码隐藏
protected void btnUploadClick(object sender, EventArgs e)
{
try
{
WebClient client = new WebClient();
NetworkCredential nc = new NetworkCredential("admin", "jetnexus");
Uri addy = new Uri(@"\\192.168.2.19\jetnexus\etc\");
client.Credentials = nc;
byte[] arrReturn = client.UploadFile(addy, FileUpload1.FileName);
}
catch (Exception ex1)
{
}
}