Meilleur auteur de réponses
ainsi qu'un fichier non identifié

Question
-
bonjour
ma dernière difficulté vient de la non reconnaissance des objets wifstream et wofstream
je vous met le code et le message d'erreur
le code :
erc CIniFile::WriteString( System::String^ sSectionName, System::String^ sKeyName, System::String^ sStrValue) { try { //A variable to hold the fetched line in wstring format System::String^ sLine; //A variable to hold the position of the searched character unsigned int iPos; //A variable to indicate whether the section in the input parameter is found bool bSectionFound = false; //A variable to indicate whether the section in the input parameter is found bool bKeyFound = false; //Handle to open the INI file in read mode wifstream hInFile; //Handle to open the INI file in write mode wofstream hOutFile; //List to hold all the sections and keys in the INI file List< System::String^>^ sListIni; //A variable to hold the position of the searched character unsigned int iKeyPos; //Close the INI file that is opened in the constructor if( CWfStream::is_open()) { CWfStream::close(); } //Open the INI file in read mode, loop till the end and insert each //line into the list. Close the INI file after the entire file is read. char* s; s = CStrConv::awcstombs((wchar_t*)m_sFileName.c_str()); hInFile.open( (char*)s, 666); CStrConv::StrFreeA( s); //If the INI file is not open then return FAILURE if (!hInFile.is_open()) { return FAILURE; } while (!hInFile.eof()) { CWfStream::getline(hInFile, sLine); if (!sLine.empty()) { sListIni->Add( sLine); } hInFile.close(); s = objStrConv.awcstombs((wchar_t*)m_sFileName.c_str()); hOutFile.open( (char*)s, 666); CStrConv::StrFreeA( s); //Open the INI file in the write mode //If the INI file is not open then return FAILURE if (!hOutFile.is_open()) { return FAILURE; } System::String^ pListIni; for each( pListIni in sListIni) { //Check whether the string is a section that is required. If yes, then set the variable to true hOutFile << pListIni << endl; if( pListIni == (L"[" + sSectionName + L"]")) { bSectionFound = true; sListIni.insert( pListIni, sKeyName + L"=" + sStrValue); //Check whether the fetched string is a key that is required. If yes, //then change its value and assign it back to the list and break out //of the while loop. iPos = pListIni->find(sKeyName); iKeyPos = pListIni->find(L"="); if( ( iPos != std::wstring::npos) && (sKeyName.size() == iKeyPos)) { pListIni->empty(); pListIni = sKeyName + L"=" + sStrValue; bKeyFound = true; } else { //If the string is not the required key, then ensure that it is not //the beginning of another section. If it is another section, and //the required key is not found within the given section, insert the //given key and its value into the list before the beginning of the //next section. After inserting the value into the list, decrement //the iterator so that the pointer will point to the beginning of //the inserted line to print it in the INI file. iPos = pListIni->find(L"["); if (iPos != std::wstring::npos) { if (!bKeyFound) { sListIni.insert( pListIni, sKeyName + L"=" + sStrValue); } } } hOutFile << pListIni << endl; } hOutFile << pListIni << endl; } //If the given section itself is not found then, write the section into the //INI file if (!bSectionFound) { hOutFile << "[" << sSectionName << "]" << endl; hOutFile << sKeyName << "=" << sStrValue << endl; } hOutFile.close(); //Open the INI file in read write mode CWfStream::open( m_sIniFileName.c_str(), L"w+", 666); return SUCCESS; } catch(...) { return FAILURE; } }//End of WriteString method
le message d'erreur :
1>..\..\..\..\Utility\IniFileManager\src\IniFile.cpp(394): error C2065: 'wifstream' : identificateur non déclaré 1>..\..\..\..\Utility\IniFileManager\src\IniFile.cpp(394): error C2146: erreur de syntaxe : absence de ';' avant l'identificateur 'hInFile' 1>..\..\..\..\Utility\IniFileManager\src\IniFile.cpp(394): error C2065: 'hInFile' : identificateur non déclaré 1>..\..\..\..\Utility\IniFileManager\src\IniFile.cpp(396): error C2065: 'wofstream' : identificateur non déclaré 1>..\..\..\..\Utility\IniFileManager\src\IniFile.cpp(396): error C2146: erreur de syntaxe : absence de ';' avant l'identificateur 'hOutFile' 1>..\..\..\..\Utility\IniFileManager\src\IniFile.cpp(396): error C2065: 'hOutFile' : identificateur non déclaré
Jean Noël Martin
Réponses
-
et le "std::" d'avant, c'est pour quand ?
Paul Bacelar, Ex - MVP VC++
- Marqué comme réponse JeanNoel53 jeudi 23 juillet 2015 18:25