存在快速检查文件的方法

编程入门 行业动态 更新时间:2024-10-11 21:25:37
本文介绍了存在快速检查文件的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好我使用以下代码但不确定我的代码是否以最佳速度运行;两次扫描目录?有没有更有效的方法来执行此操作?检查是否存在JPG或PNG。非常感谢。 我的尝试:

Hi I am using the following code but not sure if my code runs at best speed; two scans of the directory? Any more efficient way to execute this? Checks to see if a JPG or PNG exists. Many thanks. What I have tried:

<pre> 'Check if jpg or png exist and then use this image If fd3 <> "" Then fd3 = Path.GetFileNameWithoutExtension(fd3) & ".jpg" loc_a = locpath + fd3 If Dir(loc_a) <> "" Then im = loc_a Else fd3 = Path.GetFileNameWithoutExtension(fd3) & ".png" loc_a = locpath + fd3 If Dir(loc_a) <> "" Then im = loc_a End If End If End If

推荐答案

尝试: Dim basePath As String = locpath & Path.GetFileNameWithoutExtension(fd3) If File.Exists(basePath & ".jpg") Then im = basePath & ".jpg" ElseIf File.Exists(basePath & ".png") Then im = basePath & ".png" End If

更多推荐

存在快速检查文件的方法

本文发布于:2023-11-30 13:51:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650218.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:快速   文件   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!