CreateDirectory 创建文件夹

函数原型:

CreateDirectory(
  LPCTSTR lpPathName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes
);

简介:

CreateDirectory 是Win32API函数,用于创建文件夹。
     参数 lpPathName 表示路径
    参数 lpSecurityAttributes 表示安全属性

============================================================================
例子(程序段):

//设置属性
        SECURITY_ATTRIBUTES attribute;
        attribute.nLength = sizeof(attribute);
        attribute.lpSecurityDescriptor = NULL;
        attribute.bInheritHandle = FALSE;
        //创建
        if(CreateDirectoryA(“d:\\yanlei”,&attribute) == 0)
            AfxMessageBox("false");

==========================================================================
MSDN上的相关信息:

This function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.

A RAPI version of this function exists, and it is named CeCreateDirectory (RAPI).

CreateDirectory(
  LPCTSTR <>
  LPSECURITY_ATTRIBUTES < EM>
);

lpPathName

[in] Long pointer to a null-terminated string that specifies the path of the directory to be created.

There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the CreateDirectory function parses paths.

lpSecurityAttributes

[in] Ignored; set to NULL.

<>

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

CreateDirectory is not recursive. The function can create only the final directory in a path. That is, if a parent or intermediate directory does not exist, the function will fail with error message ERROR_PATH_NOT_FOUND.

Some file systems, such as NTFS file system, support compression or encryption for individual files and directories. On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent directory.

In Windows CE 5.0 and later, full path canonicalization is performed before CreateDirectory processes a path name. As a result, trailing backslashes that may appear in a user-provided path name are ignored.

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

CreateDirectory 创建文件夹,布布扣,bubuko.com

时间: 2024-10-08 20:34:16

CreateDirectory 创建文件夹的相关文章

CreateDirectory 创建文件夹 C\C++

函数原型: CreateDirectory( LPCTSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes ); 简介: CreateDirectory 是Win32API函数,用于创建文件夹.     参数 lpPathName 表示路径    参数 lpSecurityAttributes 表示安全属性 例子: 1 //设置属性 2 SECURITY_ATTRIBUTES attribute; 3 attribute.nLeng

C#创建文件夹和文件

一.创建文件夹,例: 1 if (!Directory.Exists(path)) 2 { 3 Directory.CreateDirectory(path); 4 } 二.创建文件,例: 1 global::System.IO.FileInfo josnfile = new global::System.IO.FileInfo(JsonPath); 2 if (!josnfile.Exists) 3 { 4 // 创建map.json文件 5 FileStream fs = new FileS

自动创建文件夹的两种方法

自动创建文件夹的两种方法 1.CreateDictionary() CreateDirectory(myPath, 0); //在临时文件夹中创建本应用的文件夹 原型为:BOOL WINAPI CreateDirectory(__in  LPCTSTR lpPathName, __in LPSECURITY_ATTRIBUTES lpSecurityAttributes); 其中lpPathName是要创建的目录的路径,第2个涉及安全性问题 传NULL就好了 例如: char path[MAX_

C# 在本地创建文件夹及子文件夹

1 string dict = @"d:\估价报告\"; 2 if (!Directory.Exists(dict)) 3 { 4 Directory.CreateDirectory(dict); //创建文件夹 5 } 6 string subFolder = "subfolder"; 7 string pathString = System.IO.Path.Combine(dict, subFolder); 8 if (!System.IO.File.Exist

C#创建文件夹

string path = Server.MapPath("~/DefaultImg/newDir/63/");//获取文件路径 if (!Directory.Exists(path))//如果该文件不存在 { Directory.CreateDirectory(path);//创建文件夹(创建文件夹63) } 尝试之后,它会在DefaultImg文件夹里面的newDir里面创建一个名字叫做  63   的文件件,如果只有DefaultImg 文件夹的话,它会在DefaultImg 里

.net 创建文件夹

private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 string str=UserName.Text; //获得用户名 if(!ispostback) { string TimePath = Server.MapPath(str).ToString() + "\\";//获取上传路径的物理地址 if (!Directory.Exists(TimePath))//判断文件夹是否存在 

MFC下对文件及文件夹的操作(复制、剪切、删除、创建文件夹,写文件)

一.文件夹的创建 1 void CFileOperationDlg::OnButtonMakeFolder() 2 { 3 // TODO: Add your control notification handler code here 4 UpdateData(TRUE); 5 CFileFind m_sFileFind; 6 7 if (!m_sFileFind.FindFile(m_FolderName)) 8 { 9 CreateDirectory(m_FolderName,NULL);

asp.net 文件操作小例子(创建文件夹,读,写,删)

静态生成要在虚拟目录下创建文件夹 来保存生成的页面 那么就要对文件进行操作 一.创建文件夹 using System.IO; string name = "aa"; string path = Server.MapPath("") + "\\" + name; if (Directory.Exists(path)) { Response.Write("<script>alert('文件夹已存在了!');history.go(

webApi上传服务,可重命名,可创建文件夹

webApi上传服务,根据FileName重命名,根据Path创建文件夹 /// <summary> /// 上传文件 /// </summary> /// <returns></returns> [HttpPost, Route("upload")] public IHttpActionResult UploadFile() { string defaultPath = ConfigurationManager.AppSettings[