1# Accessing Application Files (C/C++)
2
3## When to Use
4
5The **FileIO** module provides APIs for basic file operations.
6
7## Basic Concepts
8
9URI: uniquely identifies a file.
10
11## Constraints
12
13- Before performing file operations, ensure that the URI or path passed in is correct and valid.
14
15## Available APIs
16
17For details about the APIs, see [FileIO](../reference/apis-core-file-kit/_file_i_o.md).
18
19| API| Description|
20| -------- | -------- |
21| FileManagement_ErrCode OH_FileIO_GetFileLocation(char *uri, int uriLength, FileIO_FileLocation *location)| Obtains the location of a file.|
22| enum FileIO_FileLocation FileIO_FileLocation| Enumerates the file locations.|
23| enum enum FileManagement_ErrCode FileManagement_ErrCode| Enumerates the error codes used in the **FileIO** module.|
24
25## How to Develop
26
27**Adding the Dynamic Link Library**
28
29Add the following library to **CMakeLists.txt**.
30
31```txt
32target_link_libraries(sample PUBLIC libohfileio.so)
33```
34
35**Adding the Header File**
36
37```c++
38#include <filemanagement/fileio/oh_fileio.h>
39```
40
41Call **OH_FileIO_GetFileLocation** to obtain the location of a file. <br>Example:
42```c
43    void GetFileLocationExample() {
44        char *uri = "file://com.example.demo/data/storage/el2/base/files/test.txt";
45        FileIO_FileLocation location;
46        FileManagement_ErrCode ret = OH_FileIO_GetFileLocation(uri, strlen(uri), &location);
47        if (ret == 0) {
48            if (location == FileIO_FileLocation::LOCAL) {
49                printf("This file is on local.");
50            } else if (location == FileIO_FileLocation::CLOUD) {
51                printf("This file is on cloud.");
52            } else if (location == FileIO_FileLocation::LOCAL_AND_CLOUD) {
53                printf("This file is both on local and cloud.");
54            }
55        } else {
56            printf("GetFileLocation failed, error code is %d", ret);
57        }
58    }
59```
60