测试文件是否存在 [英] test for existence of file
本文介绍了测试文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何测试文件系统中是否存在文件:
如果FileExists(myVariable&" .pdf")= True
pnlMyPanel.Visible = True
结束如果
-
_____
DC G
How do I test for existence of a file in the file system:
If FileExists(myVariable & ".pdf") = True
pnlMyPanel.Visible = True
End If
--
_____
DC G
推荐答案
使用File.Exists方法。
" DC Gringo" <直流****** @ visiontechnology.net>在消息中写道
新闻:e4 ************** @ TK2MSFTNGP10.phx.gbl ...
Use the File.Exists method.
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
我如何测试文件系统中存在文件:
如果FileExists(myVariable&" .pdf")= True
pnlMyPanel.Visible = True
结束如果
-
_____
DC G
How do I test for existence of a file in the file system:
If FileExists(myVariable & ".pdf") = True
pnlMyPanel.Visible = True
End If
--
_____
DC G
您应该使用System.IO.FileInfo对象。
执行所需操作的C#代码如下:
FileInfo myFile = new FileInfo(myVariable +" .pdf" )
if(myFile.Exists)
{
pnlMyPanel.Visible = true;
}
-
mvh
Svein Terje Gaup
" DC Gringo" <直流****** @ visiontechnology.net>在消息中写道
新闻:e4 ************** @ TK2MSFTNGP10.phx.gbl ...
You should use a System.IO.FileInfo object.
The C# code for doing what you want is like this:
FileInfo myFile = new FileInfo(myVariable + ".pdf")
if(myFile.Exists)
{
pnlMyPanel.Visible = true;
}
--
mvh
Svein Terje Gaup
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
我如何测试文件系统中存在文件:
如果FileExists(myVariable&" .pdf")= True
pnlMyPanel.Visible = True
结束如果
-
_____
DC G
How do I test for existence of a file in the file system:
If FileExists(myVariable & ".pdf") = True
pnlMyPanel.Visible = True
End If
--
_____
DC G
Dim myFile As FileInfo = New FileInfo(myFileName)
如果(myFile.Exists)
myPanel.Visible = True
结束如果
真诚
Svein Terje Gaup
" DC Gringo" <直流****** @ visiontechnology.net>在消息中写道
新闻:e4 ************** @ TK2MSFTNGP10.phx.gbl ...
Dim myFile As FileInfo = New FileInfo(myFileName)
If(myFile.Exists)
myPanel.Visible = True
End If
Sincerely
Svein Terje Gaup
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
我如何测试文件系统中存在文件:
如果FileExists(myVariable&" .pdf")= True
pnlMyPanel.Visible = True
结束如果
-
_____
DC G
How do I test for existence of a file in the file system:
If FileExists(myVariable & ".pdf") = True
pnlMyPanel.Visible = True
End If
--
_____
DC G
这篇关于测试文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文