//判断文件是否存在时用FileInfo或File string SkinName = Application.StartupPath + "\\skin.txt"; FileInfo myDir = new FileInfo(SkinName); if (myDir.Exists) { } //判断目录是否存在时用Directory或DirectoryInfo string SkinName = Application.StartupPath + "\\skin"; DirectoryInfo myDir = new DirectoryInfo(SkinName); if (myDir.Exists) { }
从网易博客(http://cxwstar.blog.163.com/blog/static/4846876320112415127100/)迁移,原发表于2011年3月4日.