⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mediautilities.cs

📁 《.NET游戏编程入门经典-c#篇》
💻 CS
字号:
using System;
using System.IO;
using System.Configuration;


	/// <summary>
	/// Summary description for MediaUtilities.
	/// </summary>
public class MediaUtilities {
	//		private static string defaultPath = @"..\..\media\";
	private static string mediaPath = ConfigurationSettings.AppSettings.Get("MediaPath");
		
	public MediaUtilities() {
	}

	public static string FindFile(string filename) {
		return FindFile(mediaPath, filename);
	}

	public static string FindFile(string path, string filename) {
		// First try to load the file in the full path
		string fullName = AppendDirectorySeparator(path) + filename;
		if (File.Exists(fullName))
			return fullName;
		else
			throw new FileNotFoundException("Could not find this file.", filename);
	}

	private static string AppendDirectorySeparator(string pathname) {
		if (!pathname.EndsWith(@"\"))
			return pathname + @"\";
		else
			return pathname;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -