ASP.NET获取文件的相关知识

       string filePath = FileUpload1.PostedFile.FileName;//获取上传文件的路径
            string fileName = filePath.Substring(filePath.LastIndexOf("\") + 1);//获取文件名称
            string filesize = Convert.ToString(FileUpload1.PostedFile.ContentLength);//获取文件大小
            string fileExtend = filePath.Substring(filePath.LastIndexOf(".") + 1);//获取文件扩展名
            string fileType = FileUpload1.PostedFile.ContentType;//获取文件类型
            string serverPath = Server.MapPath("指定文件夹名称") + fileName;//保存到服务器的路径
            FileUpload1.PostedFile.SaveAs(serverPath);//确定上传文件

  

奋斗就是每天很难,可是一年一年却越来越容易; 不奋斗就是每天很容易,可是一年一年却越来越难。
原文地址:https://www.cnblogs.com/luxiaoyao/p/6054519.html