![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #2 (permalink) | ||||||||||||
| Guest | Re: if a file exists NeilOz wrote:
"start" if(!(test-path foo.file)){"file not found";break} "end" Output: PSH> ./testpath.ps1 start file not found PSH> Note: "end" does not show because of the break statement. Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: if a file exists "NeilOz" <NeilOz@xxxxxx> wrote in message news:F2452105-8530-4B5F-B098-7E3837B039CF@xxxxxx
Another option, for the sake of completion ..... [reflection.assembly]::LoadWithPartialName("Microsoft.VisualBasic") if(!([Microsoft.VisualBasic.FileIO.FileSystem]::FileExists($profile))) { Write-Host "No such file"; Return } -- Jon | ||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: if a file exists Which can be achieved without the PartialName loading ![]() [System.IO.File]::Exists(<path>) ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
| ||||||||||||||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: if a file exists Is there a way to perform 3 filename checks at one go ? Eg $file_exists = [System.IO.File]::Exists(D:\test1.txt) If i have test1.txt, test2.txt, abc.txt, are there any .net class do put everything in similar fashion : $file_exists = [System.IO.File]::Exists(D:\test1.txt, d:\test2.txt, abc.txt) if *any* $file_exists, then write-host .... "Shay Levi" <no@xxxxxx> wrote in message news:8766a944164f18ca1a6efc678646@xxxxxx
| ||||||||||||||||||||||||||||||||||||
| | #7 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: if a file exists Not with [System.IO.File]::Exists You can do it with Test-Path: "D:\test1.txt","d:\test2.txt","abc.txt" | test-path -pathtype leaf ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
| ||||||||||||||||||||||||||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ReadyBoost - Cache Exists | RugRat | Vista General | 10 | 04-14-2008 10:32 PM |
| ultimate backup error: file already exists | Chris Cowles | Vista performance & maintenance | 3 | 09-11-2007 11:51 PM |
| If file exists loop | ryanlsanders@gmail.com | PowerShell | 5 | 08-16-2007 10:05 AM |
| Get "file already exists" on trying to save a new file (after rena | D70neRd | Vista General | 1 | 07-07-2007 05:19 PM |
| Save As - file already exists | Bob Lund | Vista General | 2 | 04-10-2007 11:32 PM |