CSharpTest.Net
TrySearchPath Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : TrySearchPath Method

location
fullPath

Glossary Item Box

Returns true if the file is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception. Will not propagate errors.

Syntax

Visual Basic (Declaration) 
Public Shared Function TrySearchPath( _
   ByVal location As String, _
   ByRef fullPath As String _
) As Boolean
C# 
public static bool TrySearchPath( 
   string location,
   out string fullPath
)

Parameters

location
fullPath

Example

Library/Library.Test/TestFileUtils.cs

C#Copy Code
string found, test;

test = @"C:\This file hopefully doesn't exist on your hard drive!";
Assert.IsFalse(File.Exists(test));
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));

test = @"*<Illegal File Name?>*";
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));

test = @"*"; //<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));

test = @"????????.???"; //<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));
VB.NETCopy Code
Dim found As String, test As String

test = "C:\This file hopefully doesn't exist on your hard drive!"
Assert.IsFalse(File.Exists(test))
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

test = "*<Illegal File Name?>*"
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

test = "*"
'<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

test = "????????.???"
'<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys