Hi
I need help with to access a text file over my local network.
I need to be able to create,read, write and delete the txt file on a specific machine(s) from any computer over the network. The folder where the txt file should be created is enabled for sharing and allows other users on the network to change files (XP Pro on all machines). My code is as follows:
[code=c]
// Writing Local IP to File
fstream myfile;
myfile.open ("\\computer_na me\\folder_name \\test2.txt");
myfile << localIP;
myfile.close();
//////////////////////////////////////////////////////////////////
//Reading from File for Local IP
string line;
fstream myfile ("\\computer_na me\\folder_name \\test2.txt");
if (myfile.is_open ())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
[/code]
I don't seem to be able to create, read, write, etc the file using
[code=c]
fstream myfile;
myfile.open ("\\computer_na me\\folder_name \\test2.txt");
[/code]
It seems like the path is wrong although if I paste the path into 'RUN' I obtain the correct folder/file.
Can you please help with this. Also I need help on deleting the file after reading.
Thank you
S
I need help with to access a text file over my local network.
I need to be able to create,read, write and delete the txt file on a specific machine(s) from any computer over the network. The folder where the txt file should be created is enabled for sharing and allows other users on the network to change files (XP Pro on all machines). My code is as follows:
[code=c]
// Writing Local IP to File
fstream myfile;
myfile.open ("\\computer_na me\\folder_name \\test2.txt");
myfile << localIP;
myfile.close();
//////////////////////////////////////////////////////////////////
//Reading from File for Local IP
string line;
fstream myfile ("\\computer_na me\\folder_name \\test2.txt");
if (myfile.is_open ())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
[/code]
I don't seem to be able to create, read, write, etc the file using
[code=c]
fstream myfile;
myfile.open ("\\computer_na me\\folder_name \\test2.txt");
[/code]
It seems like the path is wrong although if I paste the path into 'RUN' I obtain the correct folder/file.
Can you please help with this. Also I need help on deleting the file after reading.
Thank you
S
Comment