iOS文件共享,无法写入Document文件夹

时间:2013-04-12 03:30:17

标签: c++ ios file-io

您好我发现自己无法写入ios上的文件。这是路径:

知道我做错了什么吗?应用程序支持iTunes文件共享设置为YES。

/var/mobile/Applications/BB0464AB-2F13-4B23-81BF-FBA0D5A40D9A/MyApp.app/Documents/a.txt

        ofstream myfile;
        myfile.open ("/var/mobile/Applications/BB0464AB-2F13-4B23-81BF-FBA0D5A40D9A/MyApp.app/Documents/a.txt");
        myfile << "Writing this to a file.\n";
        myfile.close();


        string line;
        ifstream myfile2 ("/var/mobile/Applications/BB0464AB-2F13-4B23-81BF-FBA0D5A40D9A/MyApp.app/Documents/a.txt");
        if (myfile2.is_open())
        {
            while ( myfile2.good() )
            {
                getline (myfile2,line);
                cout << line << endl;
            }
            myfile2.close();
        } else std::cout << "Unable to open file";

0 个答案:

没有答案