Monday 7 November 2011

Uploading files without using file upload controls from file path in asp.net with c#

This Code is usable when u know the achual path of client file and you want to get (save and upload) that file in your server computer or you want to upload file through a path that client type in a textbox not using file upload.

WebClient client= new WebClient();
string FullFilePath = txtFilePath.Text;
string FileName = Path.GetFileName(FullFilePath);

Byte[] bytes = client.DownloadData(FullFileName);
if (bytes.Length > 0)
{
client.DownloadFile(FullFilePath, Server.MapPath("File/" + FileName));
}

No comments:

Post a Comment