| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1035 人关注过本帖
标题:[求助]怎样建文件夹
只看楼主 加入收藏
jerry_yuan
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2004-11-6
收藏
 问题点数:0 回复次数:2 
[求助]怎样建文件夹

怎样在磁盘上建一个文件夹?

搜索更多相关主题的帖子: 文件 磁盘 
2004-11-07 16:20
水易雨辰
Rank: 1
等 级:新手上路
帖 子:177
专家分:0
注 册:2004-4-15
收藏
得分:0 

来自在.netframework文档:

示例 [Visual Basic, C#, C++] 下面的示例创建并删除指定目录。 [Visual Basic] Imports System Imports System.IO Imports Microsoft.VisualBasic

Public Class Test Public Shared Sub Main() ' Specify the directory you want to manipulate. Dim path As String = "c:\MyDir"

Try ' Determine whether the directory exists. If Directory.Exists(path) Then Console.WriteLine("That path exists already.") Return End If

' Try to create the directory. Dim di As DirectoryInfo = Directory.CreateDirectory(path) Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path))

' Delete the directory. di.Delete() Console.WriteLine("The directory was deleted successfully.")

Catch e As Exception Console.WriteLine("The process failed: {0}.", e.ToString()) End Try End Sub End Class

[C#] using System; using System.IO;

class Test { public static void Main() { // Specify the directory you want to manipulate. string path = @"c:\MyDir";

try { // Determine whether the directory exists. if (Directory.Exists(path)) { Console.WriteLine("That path exists already."); return; }

// Try to create the directory. DirectoryInfo di = Directory.CreateDirectory(path); Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));

// Delete the directory. di.Delete(); Console.WriteLine("The directory was deleted successfully."); } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } finally {} } }


授人以鱼,不如授人以渔!
2004-11-07 22:06
idle0206
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2004-12-9
收藏
得分:0 
多谢分享!!!!!!!
2004-12-09 12:23
快速回复:[求助]怎样建文件夹
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067691 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved