如何识别文件的类型和大小 [英] how to identify the file type and size of a file

查看:136
本文介绍了如何识别文件的类型和大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我已经上传了文件...
我想将有关文件的那些信息存储在我的数据库中....
喜欢
文件名,
文件类型,
扩展名,
尺寸,
文件路径.
我也想将其存储在数据库中...
我知道要识别文件名:

hi...
i have uploaded a file...
i want to store those info about file in my database....
like
file name,
file type,
extension,
size,
file path.
and also i want to store it in database...
i know to identify the filename:

fname.InnerHtml=MyFile.PostedFile.FileName


尺寸:


for size:

clength.InnerHtml=MyFile.PostedFile.ContentLength...


推荐答案

使用FileInfo类获取上传文件的详细信息.

检查此链接
http://msdn.microsoft.com/en-us/library/system.io. fileinfo.aspx [^ ]
use FileInfo Class to get the upload file details.

check this link
http://msdn.microsoft.com/en-us/library/system.io.fileinfo.aspx[^]


使用HttpPostedFile和以下属性:
ContentLength:上载文件的大小,以字节为单位
ContentType:上传文件的类型,即"image/gif"
FileName:客户端系统上载文件的完整路径,

或通过以下网址获取所有内容:使用ASP.NET上传文件 [
use the HttpPostedFile and following properties :
ContentLength: size of uploaded file in bytes
ContentType: type of uploaded file, i.e. "image/gif"
FileName: full path to uploaded file on client''s system,

or get everything at :File Upload with ASP.NET[^]


使用
FileInfo fi = new FileInfo(filepath);
            fi.Extension;


而且U可以找到更多解决方案,可以解决您的需求


and U can find many more it will solve ur requirement


这篇关于如何识别文件的类型和大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆