harmony 鸿蒙Environment

2025-06-12 浏览 (1)

Environment

Overview

Provides the capability of obtaining the root directory of user files.

Since: 12

Summary

Files

NameDescription
oh_environment.hDefines the native APIs used to obtain the sandbox paths of the user files.

Functions

NameDescription
FileManagement_ErrCode OH_Environment_GetUserDownloadDir (char **result)Obtains the sandbox path of the Download root directory. Only 2-in-1 devices are supported.
FileManagement_ErrCode OH_Environment_GetUserDesktopDir (char **result)Obtains the sandbox path of the Desktop root directory. Only 2-in-1 devices are supported.
FileManagement_ErrCode OH_Environment_GetUserDocumentDir (char **result)Obtains the sandbox path of the Document root directory. Only 2-in-1 devices are supported.

Function Description

OH_Environment_GetUserDesktopDir()

FileManagement_ErrCode OH_Environment_GetUserDesktopDir (char ** result)

Description Obtains the sandbox path of the Desktop root directory.

Since: 12

Parameters

NameDescription
resultDouble pointer to the sandbox path of the Desktop root directory obtained. You also need to include malloc.h and use free() to release the memory allocated.

Required permissions

ohos.permission.READ_WRITE_DESKTOP_DIRECTORY

Return value

FileManagement_ErrCode

OH_Environment_GetUserDocumentDir()

FileManagement_ErrCode OH_Environment_GetUserDocumentDir (char ** result)

Description Obtains the sandbox path of the Document root directory.

Since: 12

Parameters

NameDescription
resultDouble pointer to the sandbox path of the Document root directory obtained. You also need to include malloc.h and use free() to release the memory allocated.

Required permissions

ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY

Return value

FileManagement_ErrCode

OH_Environment_GetUserDownloadDir()

FileManagement_ErrCode OH_Environment_GetUserDownloadDir (char ** result)

Description Obtains the sandbox path of the Download root directory.

Since: 12

Parameters

NameDescription
resultDouble pointer to the path of the Download root directory obtained. You also need to include malloc.h and use free() to release the memory allocated.

Required permissions

ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY

Return value

FileManagement_ErrCode

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Core File Kit

harmony 鸿蒙FileIO

harmony 鸿蒙FileShare_PolicyErrorResult

harmony 鸿蒙FileShare_PolicyInfo

harmony 鸿蒙error_code.h

harmony 鸿蒙File Management Error Codes

harmony 鸿蒙FileShare

harmony 鸿蒙FileUri

harmony 鸿蒙@ohos.application.BackupExtensionAbility (Backup and Restore Extension Capability) (System API)

harmony 鸿蒙@ohos.application.BackupExtensionAbility (BackupExtensionAbility)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/pwRLBr