Click here to Skip to main content
15,885,823 members
Articles / Programming Languages / Visual Basic

Template Based Code Generator

Rate me:
Please Sign up or sign in to vote.
4.67/5 (33 votes)
20 Nov 2007CPOL13 min read 93.2K   4.1K   116  
A template based, command-line oriented .NET code generator
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Arebis.Utils
{
	/// <summary>
	/// Utility class containing several static utility related to the files or the file system.
	/// </summary>
	public static class FileUtils
	{
		/// <summary>
		/// Returns the full filepath of an existing file matching the given filename
		/// in one of the given path directories. Returns null if no file found.
		/// </summary>
		public static string FindInPath(string filename, string[] path)
		{
			// No filename results in null path:
			if ((filename == null) || (filename.Length == 0)) return null;

			// Search each path directory for the file:
			foreach (string dir in path)
			{ 
				string file = Path.Combine(dir, filename);
				if (File.Exists(file)) return file;
			}

			// Return null if not found:
			return null;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect AREBIS
Belgium Belgium
Senior Software Architect and independent consultant.

Comments and Discussions