What I am trying to do is create an encryption tool. It converts a file to string. That string is then to be encrypted. However, while converting file to string and again saving that file (for testing purposes), the returned file is not the same as the original file and does not open even after I change the extension. Please help:
String^ fileNME = textBox1->Text; //File is selected via fileopendialog and then copied to TextBox1
//Convert from System::String to std::string. result is actually a string that holds the filename.
string result("a");
result = marshal_as<std::string>( fileNME );
string fileToEncryptasString;
fileToEncryptasString = fileToString(result);
myfile.open ("filecopy.txt");
myfile << fileToEncryptasString;
myfile.close();
//File to String function is this:
string fileToString(const string& filename)
{
ifstream file(filename, ios::binary);
if (!file) return "";
string str(istreambuf_iterator<char>(file),
(istreambuf_iterator<char>()));
return str;
}