[英]access to downloads folder in phone in c language
我需要用C語言到達“下載”之類的文件夾,這是我下載文件夾的路徑:/ run / user / 1002 / gvfs / mtp:host =%5Busb%3A001%2C022%5D /אחסוןפנימי/ Download
我在java(可以工作)中有代碼,但是不知道如何在c中做到這一點:
File root2 = android.os.Environment.getExternalStorageDirectory();
File sdcard = new File(root2.getAbsolutePath() + "/download");
sdcard.mkdirs();
File file = new File(sdcard, "XYZ1.txt");
if (!file.exists()) {
try {
file.createNewFile();
}catch (IOException e) {
}
}
我想知道如何進入C語言tnx的下載文件夾以獲取幫助
上面的等效C代碼將是這樣的:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE * fp;
FILE *fp = fopen("<relative/absolute path>/XYZ1.txt", "ab+"); //This create file if not present
if (fp==NULL){
printf("Could not create file in loc ..");
}
......
// Do your stuff with the file
......
fclose(fp); //Close the file before leaving
}
有關文件IO和文件訪問模式的更多信息,請點擊此處
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.