• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
海凡-沈
博客园    首页    新随笔    联系   管理    订阅  订阅

c# 文件操作的问题

有这么一段程序

using System;
using System.IO;
class text
{
    public static void Main()
    {
        //指定详细的目录的路径
        string path = @"e:\what";
        string target = @"e:\name";
        try
        {
            //判断目录是否存在
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                Directory.CreateDirectory(path + @"\mingzi");//创建的是目录
                File.Create(path + @"\mm.txt");
            }

            if (Directory.Exists(target))
            {
                Directory.Delete(target);

            }

            //移动此目录

            Directory.Move(path, target);
       
   }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
        finally
        {
        }

    }
}

注意红色的部分,我现在想在这个文件下创建一个mm.txt的文件,可是在程序运行的时候,却爆出了这么一个异常:
对路径“e:\what”的访问被拒绝,请问是为什么啊?

posted @ 2008-01-16 11:06  海凡-沈  阅读(73)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3