我正在尝试添加一个我自己写入HttpPostedFile类的IsImage属性,这样如果用户上传文件,我可以这样做:
FileUpload1.PostedFile.IsImage
Run Code Online (Sandbox Code Playgroud)
我怎么能在C#中做到这一点?
您可以使用扩展方法来实现此目的.
public static class HttpPostedFileExtension
{
public static bool IsImage(this HttpPostedFile file)
{
/*your method code goes here*/
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
754 次 |
| 最近记录: |