SnippetBank
Net
Check If File Exists In C#
This snippet checks to see if a file exists using the FileInfo Class.
using System
;
using System.
IO
;
class Program
{
static
void
Main
(
string
[
]
args
)
{
FileInfo file
=
new FileInfo
(
"file.txt"
)
;
if
(
file.
Exists
)
{
Console.
Write
(
"File Exists"
)
;
}
else
{
Console.
Write
(
"File Does Not Exist"
)
;
}
Console.
ReadKey
(
)
;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
No comments:
Post a Comment