Asp.net checks whether image files exist in the specified folder in the specified path.

Source: Internet
Author: User
  1. /// <Summary>
  2. /// Determine whether an image exists
  3. /// </Summary>
  4. /// <Param name = "folderPath"> specify the folder path </param>
  5. /// <Returns> bool </returns>
  6. Public BoolJudgeExpensionName (StringFolderPath)
  7. {
  8. BoolIsTp =False;
  9. If(Directory. Exists (folderPath ))
  10. {
  11. Foreach(StringItemFilePathInDirectory. GetFiles (folderPath ))
  12. {
  13. FileInfo fi =NewFileInfo (itemFilePath );
  14. // Creation time fi. CreationTime;
  15. // Obtain the time fi. LastAccessTime for the last access to the current directory
  16. // Obtain the time fi. LastWriteTime of the last written file directory
  17. If(Fi. extension. equals (". jpg ") | fi. extension. equals (". JPG ") | fi. extension. equals (". jpge ") | fi. extension. equals (". JPEG ") | fi. extension. equals (". gif ") | fi. extension. equals (". GIF "))
  18. {
  19. IsTp =True;
  20. Break;
  21. }
  22. Else
  23. IsTp =False;
  24. }
  25. }
  26. ReturnIsTp;
  27. }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.