Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofFile cannot write to file

$
0
0

@a__ wrote:

For some reason I’m unable to write to file using ofFile(). of_v0.10.1_vs2017_release. See example below, what am I doing wrong?

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
	string data = "TEST!";
	ofFile userDataFile(ofToDataPath("userData.json"));
	userDataFile.create();
	if (!userDataFile.canWrite()) ofLogNotice("setup") << "Cannot write to userData.json!" << endl;
	userDataFile << data;
	userDataFile.close();
	ofLogNotice("setup") << "Just finished writing to and closing userData.json." << endl;
}

The file gets created but is empty (0kb size).

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles