VB/.Net如果文件存在布尔值 [英] VB/.Net If File Exists Boolean

查看:72
本文介绍了VB/.Net如果文件存在布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试创建一个函数,该函数将监视新文件的目录.文件名长度为20个字符,包括日期和随机性.

我尝试过类似的操作:
DimstrLookupPath as string =("C:\ somefolder \ * _ 0513 *")
子ChcekForFile()
执行直到System.IO.File.Exists(strLookupPath)


但这不起作用-如果我不知道文件的全名,还有其他想法吗?

TIA

Edward

Hi All,

I am trying to create a function that will watch a dir for a new file. The file names are 20 char long, including date, and randomness.

I tried something like:
DimstrLookupPath as string = ("C:\somefolder\*_0513*")
sub ChcekForFile()
Do until System.IO.File.Exists(strLookupPath)


but this doesn''t work - any other thoughts if I don''t know the full name of the file?

TIA

Edward

推荐答案

您要FileSystemWatcher,但要注意:

FileSystemWatcher-纯混沌(第1部分,共2部分) [ FileSystemWatcher-纯混沌(第2部分,共2部分) [
You want FileSystemWatcher, but beware:

FileSystemWatcher - Pure Chaos (Part 1 of 2)[^]

FileSystemWatcher - Pure Chaos (Part 2 of 2)[^]

How it reacts depends on what application is placing the file in the folder (see the Part 2 article above).


您需要执行以下操作:
You need to do something like:
Dim files As String() = Directory.GetFiles("C:\somefolder\", "*_0513*")



这样,您可以使用通配符来执行搜索.



That way you can use wildcards to perform your searches.


这篇关于VB/.Net如果文件存在布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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