- Aug
- 2,294
- 111
Further to ISFILE with URL , PowerShell may provide a solution with System.Uri
Example:
or
To use just the IsFile method;
which returns
To call this from TCC;
Using with a local file as the argument, both of these examples return the same result;
These all work with PowerShell 2.0 and above.
Joe
Example:
Code:
[System.Uri]'http://jpsoft.com'
AbsolutePath : /
AbsoluteUri : http://jpsoft.com/
Authority : jpsoft.com
Host : jpsoft.com
HostNameType : Dns
IsDefaultPort : True
IsFile : False
IsLoopback : False
IsUnc : False
LocalPath : /
PathAndQuery : /
Port : 80
Query :
Fragment :
Scheme : http
OriginalString : http://jpsoft.com
DnsSafeHost : jpsoft.com
IsAbsoluteUri : True
Segments : {/}
UserEscaped : False
UserInfo :
or
Code:
[System.Uri]'file:///C:/utils/4utils.txt'
AbsolutePath : C:/utils/4utils.txt
AbsoluteUri : file:///C:/utils/4utils.txt
Authority :
Host :
HostNameType : Basic
IsDefaultPort : True
IsFile : True
IsLoopback : True
IsUnc : False
LocalPath : C:\utils\4utils.txt
PathAndQuery : C:/utils/4utils.txt
Port : -1
Query :
Fragment :
Scheme : file
OriginalString : file:///C:/utils/4utils.txt
DnsSafeHost :
IsAbsoluteUri : True
Segments : {/, C:/, utils/, 4utils.txt}
UserEscaped : False
UserInfo :
To use just the IsFile method;
Code:
([System.Uri]'http://jpsoft.com').IsFile
which returns
Code:
False
To call this from TCC;
Code:
powershell -noprofile -command ([System.Uri]'http://jpsoft.com').IsFile
Using with a local file as the argument, both of these examples return the same result;
Code:
PS C:\utils> ([System.Uri]'file:///C:/utils/4utils.txt').IsFile
True
PS C:\utils> ([System.Uri]'C:/utils/4utils.txt').IsFile
True
These all work with PowerShell 2.0 and above.
Joe