扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:builder.com.cn 2007年5月10日
关键字:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace TRDirectory {
class Program {
static void Main(string[] args) {
string testPath = "c:\\test";
if (Path.HasExtension(testPath)) {
Console.WriteLine("This is a file path, not a directory.");
} else {
if (Directory.Exists(testPath)) {
Console.WriteLine("This directory already exists.");
} else {
try {
Directory.CreateDirectory(testPath);
} catch (IOException ex) {
Console.WriteLine("Error creating directory {0} - {1}", testPath, ex.Message.ToString());
} }
if (Directory.Exists(testPath)) {
try {
Directory.Move(testPath, "c:\\techrepublic");
} catch (IOException ex) {
Console.WriteLine("Error moving directory {0} - {1}", testPath, ex.Message.ToString());
} }
if (Directory.Exists("c:\\techrepublic")) {
try {
Directory.Delete("c:\\techrepublic", true);
} catch (IOException ex) {
Console.WriteLine("Error deleting directory c:\\techrepublic - {0}", ex.Message.ToString());
} } } } } }
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。