您现在的位置: 天极网 > 软件频道 > 设计在线 > 网页UI设计 > 利用API创建文件目录
全文

利用API创建文件目录

2000-09-24 00:00作者:李志东出处:VB编程乐园责任编辑:
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Private Type SECURITY_ATTRIBUTES
  nLength As Long
  lpSecurityDescriptor As Long
  bInheritHandle As Long
End Type

Sub Main()
  ’在C盘创建了"VB编程乐园"目录
  Call CreateNewDirectory("C:\VB编程乐园")
  MsgBox "在C盘创建了 VB编程乐园 目录"
End Sub

Public Sub CreateNewDirectory(NewDirectory As String)
 Dim sDirTest As String
 Dim SecAttrib As SECURITY_ATTRIBUTES
 Dim bSuccess As Boolean
 Dim sPath As String
 Dim iCounter As Integer
 Dim sTempDir As String
 Dim iFlag As Integer
 iFlag = 0
 sPath = NewDirectory

If Right(sPath, Len(sPath)) $#@60;$#@62; "\" Then
  sPath = sPath & "\"
End If

iCounter = 1
Do Until InStr(iCounter, sPath, "\") = 0
  iCounter = InStr(iCounter, sPath, "\")
  sTempDir = Left(sPath, iCounter)
  sDirTest = Dir(sTempDir)
  iCounter = iCounter + 1

’创建目录

  SecAttrib.lpSecurityDescriptor = &O0
  SecAttrib.bInheritHandle = False
  SecAttrib.nLength = Len(SecAttrib)
  bSuccess = CreateDirectory(sTempDir, SecAttrib)
Loop
End Sub
共1页。 1
相关搜索:
相关文章及软件
热门关注
特别推荐
网友关注
软件下载
娱乐下载
驱动下载
热评排行
群乐关注结束-->
文章排行
本周
本月
最近更新
关于我们|网站律师|天极服务|电子杂志|RSS订阅|加入我们|网站地图
TMG
Copyright (C) 1999-2008 Chinabyte.com, All Rights Reserved 版权所有 天极网络
商务联系、网站内容、合作建议:010-82657868
版权声明 在线提交意见反馈 Powered by 天极内容管理平台CMS4i
经营性网站备案信息 网警备案 中国网站排名
天极传媒:天极网|比特网|IT专家网|IT商网|52PK游戏网|IT分众