Asp.net File Upload

Import the following Namespace
using System.IO;

1. For Full File Name With Path
FileUpload1.PostedFile.FileName;
2.Get Client Directory for that File
Path.GetDirectoryName(FileUpload1.PostedFile.FileName);
3.Get File Extension
Path.GetExtension(FileUpload1.PostedFile.FileName).ToString().Trim().Remove(0, 1);
4.Get Only File Name Without Extension
Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName);
5.Get File Size
FileUpload1.PostedFile.ContentLength;
6. To Save File on Server on Your Location
string SaveLocation;
SaveLocation = Server.MapPath(“..\\UploadFile\\YourFoldername”) + “\\” + FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(SaveLocation);

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s