I'm using Linux, I mounted a Azure file share named fileshare01.
Then I wrote a program to create a file in the fileshare01 using C++
Here is my code `
#include <iostream>
#include <fstream>
#include <filesystem>
using namespace std;
int main() {
// Set the file path
string filePath = "randompath/fileshare01/aef.txt";
// Check if file already exists
if (filesystem::exists(filePath)) {
// Print a message indicating the file already exists
cout << "Error: File already exists." << endl;
return 0;
}
// Create the file
ofstream fileStream(filePath);
if (fileStream.is_open()) {
// Write to the file
fileStream << "hello" << endl;
// Close the file
fileStream.close();
// Print a message indicating success
cout << "File created successfully!" << endl;
} else {
// Print a message indicating failure
cout << "Error: Could not create file." << endl;
}
return 0;
}
`
It worked, but the official code on the documentation is Documentation
Have I stumbled upon the wrong documentation? Or my code is completely wrong? I'm a beginner and some help will really help me alot.