Does the network path available where you are publishing the application?
Network path configured in your local pc but not in the server.
So you need to configure the network drive in the server.
It is possible to save the file in network path.
Refer below example.
HTML
<asp:FileUpload ID="fuUpload" runat="server" />
<asp:Button Text="Upload" runat="server" OnClick="OnUpload" />
Namespaces
C#
using System.IO;
VB.Net
Imports System.IO
Code
C#
protected void OnUpload(object sender, EventArgs e)
{
string networkPath = @"H:\\";
string filePath = networkPath + Path.GetFileName(fuUpload.PostedFile.FileName);
using (Stream stream = fuUpload.PostedFile.InputStream)
{
using (BinaryReader br = new BinaryReader(stream))
{
byte[] bytes = br.ReadBytes((int)stream.Length);
File.WriteAllBytes(filePath, bytes);
}
}
}
VB.Net
Protected Sub OnUpload(ByVal sender As Object, ByVal e As EventArgs)
Dim networkPath As String = "H:\\"
Dim filePath As String = networkPath & Path.GetFileName(fuUpload.PostedFile.FileName)
Using stream As Stream = fuUpload.PostedFile.InputStream
Using br As BinaryReader = New BinaryReader(stream)
Dim bytes As Byte() = br.ReadBytes(CInt(stream.Length))
File.WriteAllBytes(filePath, bytes)
End Using
End Using
End Sub