How I can write a String to a file using juce_fileWrite?

I know I’m missing the obvious but how I can write a String to a file using juce_fileWrite? I thought of:

int written = juce_fileWrite(fh, (void*)temp.toUTF8(), temp.length());

or something similar, but I get a link error:

unresolved external symbol “int __cdecl juce::juce_fileWrite(void *,void *,int)” (?juce_fileWrite@juce@@YAHPAX0H@Z)

This code is in juce_File.cpp.

Thanks

you don’t

File f ( T("C:\\filepath\\filename.txt" );

String s ( T( "Love is the law, love under will." ) );

f.replaceWithText ( s );

// or....

f.appendText( s );

But what if for some reason I don’t want to use the File class? Is there no way to get the String buffer? It doesn’t matter now as I’ve redesigned the code to use File but it seems a touch odd.

Why on earth would you have any problem using the File class? That’s what it’s there for…

1 Like

I was adding functionality to the File class, which led to recursion. Don’t ask! I’ll let you scratch your head! :smiley:

2 Likes