标题:[求助]怎样建文件夹
只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-7272-1-1.html




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

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