Click here to Skip to main content
16,018,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to create an ini file through coding. If on application path ini file is not found then application itself create the ini file with the section and the name. And after creation the default value is filled from the code. Is this possible in embedded visual c++? If yes the tell me and help me to solve this problem. My basic condition is that user never create ini file and never change the field of that ini file.Do evething from the code. Please help me.
Posted

C# :
if (!System.IO.File.Exists("YourFileName.ini"))
{
    System.IO.File.Create("YourFileName.ini");
}



Visual C++ :
C++
if (!File::Exists("YourFileName.ini"))
{
    File::Create("YourFileName.ini");
}
 
Share this answer
 
v2
SQL
I create the ini file run time but whenever I write any value in the section using WriteProfileString() it requires the registry key.

CFile obFile;

if( obFile.Open( strAppIniPath, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite ))
{
        AfxMessageBox(_T("File Opened"),IDOK,NULL);
    bResult = theApp.WriteProfileString(_T("General"), _T("FirstName"), _T("String1"));
    bResult = theApp.WriteProfileString(_T("General"),_T("LastName"), _T("String2"));
}
else
{
    AfxMessageBox(_T("Unable to Open File"),IDOK,NULL);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900