search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 1,273 views | 23/01/2016 17:38

You can use Test-Path to test if file is exist.

But you can also use [System.IO.File]::Exists() to check it fast.

1
[System.IO.File]::Exists("Your File Path")

You can use in if block to check it on one line:

1
2
3
4
if ([System.IO.File]::Exists("C:\setup.log"))
{
Write-Output "File Exist"
}

It will also use less memory.