如何检查文件夹中是否已存在文件 [英] How to check if file already exists in the folder
本文介绍了如何检查文件夹中是否已存在文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一些文件复制到文件夹.我正在使用以下语句来检查源文件是否存在
Hi,
I am trying to copy some files to folder. I am using the following statement to check if the source fie exists
If My.Computer.FileSystem.FileExists(fileToCopy) Then
但是我不知道如何在复制之前检查文件夹中是否存在文件.
请指教.
谢谢和最诚挚的问候,
Furqan
But I donot know how to check if file exists in the folder before copying.
Please advise.
Thanks and best regards,
Furqan
推荐答案
If System.IO.File.Exists(Dir + filename) Then
尝试
Dim MyFile As New FileInfo("FileLocation")
If MyFile.Exists() Then
MessageBox.Show("File found.")
Else
MessageBox.Show("File not found.")
End If
参考链接:-
MSDN- [File.Exists方法] [
Reference Link :-
MSDN-[File.Exists Method][^] which will responsible to determines whether the specified file exists.
这很简单:
It''s Very Simple :
If System.IO.File.Exists("Path of the Folder with File Name") Then
MessageBox.Show("Exist")
Else
MessageBox.Show("Not Exist")
End If
或
Or
If My.Computer.FileSystem.FileExists("Path of the Folder with File Name") Then
MessageBox.Show("Exist")
Else
MessageBox.Show("Not Exist")
End If
这篇关于如何检查文件夹中是否已存在文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文