pFile = CreateFile(SaveDlg->FileName.c_str(), // pointer to name of the file
GENERIC_WRITE, // access (read-write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE,// share mode
NULL, // pointer to security attributes
OPEN_ALWAYS, // how to create
FILE_ATTRIBUTE_NORMAL,// file attributes
NULL); // handle to file with attributes to copy
if (pFile == NULL)
{
ShowMessage("Cannot create output file");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
WriteFile(pFile, strData, 255, NULL, NULL);
}
Liudi pomogite. Zabludilsia. Otkrytije i zapis v fail
Mne nuzno eti stroki vsunut v fail. Nu tipa ctoto logfaila sdelat.
Proboval tak:
Код:
Ne Rabotaet. Piset vsiakuju gadast v fail.
Proboval tak:
Код:
FILE *LogFile;
if ((LogFile = fopen(SaveDlg->FileName.c_str(), "wt")) == NULL)
{
ShowMessage("Cannot open input file.");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
fputc(strData.c_str(), LogFile);
}
if ((LogFile = fopen(SaveDlg->FileName.c_str(), "wt")) == NULL)
{
ShowMessage("Cannot open input file.");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
fputc(strData.c_str(), LogFile);
}
Toze ne mogu zastavit zapisat v fail.
Podskozite kak lutse eto sdelat.
Liubyje varianty odobriajutsia.
а как насчет того, чтобы вместо fputc заюзать fputs ? :)
Цитата:
Originally posted by Underworld
Delo takoje. Est lisbox, tama xraniatsia stroki.
Mne nuzno eti stroki vsunut v fail. Nu tipa ctoto logfaila sdelat.
Proboval tak:
Ne Rabotaet. Piset vsiakuju gadast v fail.
Proboval tak:
Toze ne mogu zastavit zapisat v fail.
Podskozite kak lutse eto sdelat.
Liubyje varianty odobriajutsia.
Delo takoje. Est lisbox, tama xraniatsia stroki.
Mne nuzno eti stroki vsunut v fail. Nu tipa ctoto logfaila sdelat.
Proboval tak:
Код:
pFile = CreateFile(SaveDlg->FileName.c_str(), // pointer to name of the file
GENERIC_WRITE, // access (read-write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE,// share mode
NULL, // pointer to security attributes
OPEN_ALWAYS, // how to create
FILE_ATTRIBUTE_NORMAL,// file attributes
NULL); // handle to file with attributes to copy
if (pFile == NULL)
{
ShowMessage("Cannot create output file");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
WriteFile(pFile, strData, 255, NULL, NULL);
}
GENERIC_WRITE, // access (read-write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE,// share mode
NULL, // pointer to security attributes
OPEN_ALWAYS, // how to create
FILE_ATTRIBUTE_NORMAL,// file attributes
NULL); // handle to file with attributes to copy
if (pFile == NULL)
{
ShowMessage("Cannot create output file");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
WriteFile(pFile, strData, 255, NULL, NULL);
}
Ne Rabotaet. Piset vsiakuju gadast v fail.
Proboval tak:
Код:
FILE *LogFile;
if ((LogFile = fopen(SaveDlg->FileName.c_str(), "wt")) == NULL)
{
ShowMessage("Cannot open input file.");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
fputc(strData.c_str(), LogFile);
}
if ((LogFile = fopen(SaveDlg->FileName.c_str(), "wt")) == NULL)
{
ShowMessage("Cannot open input file.");
return;
}
strList = m_pLBxLog->Items;
for(int i = 0; i < strList->Count; i++)
{
strData = strList->Strings.c_str();
strData += "\n";
fputc(strData.c_str(), LogFile);
}
Toze ne mogu zastavit zapisat v fail.
Podskozite kak lutse eto sdelat.
Liubyje varianty odobriajutsia.
Привет изобретателям велосипедов :). А так?
Код:
ListBox1->Items->SaveToFile("C:\\logfile.log");
Цитата:
Originally posted by honeybeer
Привет изобретателям велосипедов :). А так?
Привет изобретателям велосипедов :). А так?
Код:
ListBox1->Items->SaveToFile("C:\\logfile.log");
Hmm. A vot tak ne proboval :)
Spasibo vsem za varianty ;)