本文整理汇总了C++中TStringList::LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TStringList::LoadFromFile方法的具体用法?C++ TStringList::LoadFromFile怎么用?C++ TStringList::LoadFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStringList
的用法示例。
在下文中一共展示了TStringList::LoadFromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/*=============================================================================
*NAME :main
:
*MODULE :Test.cpp
:
*FUNCTION :メイン処理関数です
:
*PROGRAMMED :Y.Sasai
*HISTORY :
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.13 Y.Sasai Ver.0.00 初期作成
*/
int main( int argc, char* argv[] )
{
TStringList slist; // 2003.02.13 Y.Sasai Ver.0.00 StringList.cpp読み込み用
TStringList ysini; // 2003.02.13 Y.Sasai Ver.0.00 YSIniFiles.cpp読み込み用
TYSIniFile ifile( "test.ini" ); // 2003.02.13 Y.Sasai Ver.0.00 Iniファイルクラス
slist.LoadFromFile( "q:\\VCTest\\StringList.cpp" ); // 2003.02.13 Y.Sasai Ver.0.00 読み込み
ysini.LoadFromFile( "q:\\VCTest\\YSIniFiles.cpp" ); // 2003.02.13 Y.Sasai Ver.0.00 読み込み
ifile.WriteStringList( "StringList.cpp", "Source", slist ); // 2003.02.13 Y.Sasai Ver.0.00 書き込みだ
ifile.WriteStringList( "YSIniFiles.cpp", "Source", ysini ); // 2003.02.13 Y.Sasai Ver.0.00 書き込みだ
ifile.UpdateFile();
return 0;
}
示例2: LoadTimer
void __fastcall TfrmMain::LoadTimer(TObject *Sender)
{
LoadSetting();
if (FileExists(String(LoginerPath) +"\\Data\\"+ GameAccount + "\\Items.dat"))
{
TStringList *list = new TStringList();
list->LoadFromFile(String(LoginerPath) +"\\Data\\"+ GameAccount + "\\Items.dat");
for (int i = 0; i < list->Count; i++)
{
unsigned int ItemID;
ItemID = _wtoi(list->Strings[i].w_str());
AnsiString name = String(GetItemName(ItemID));
if (name.IsEmpty())
{
name.sprintf(TEXT("未知物品(編號:%d)"), ItemID);
}
int index = list_drop->Items->IndexOfObject((TObject *)ItemID);
if (index > -1)
list_drop->Items->Delete(index);
index = list_filter->Items->IndexOfObject((TObject *)ItemID);
if (index < 0)
list_filter->Items->AddObject(name, (TObject *)ItemID);
}
delete list;
}
Load->Enabled = false;
}
示例3: TVPGetConfigFileOptions
//---------------------------------------------------------------------------
static TStringList * TVPGetConfigFileOptions(AnsiString filename)
{
// load .cf file
AnsiString errmsg;
if(!FileExists(filename))
errmsg = "file not found.";
TStringList * ret = new TStringList();
if(errmsg == "")
{
try
{
ret->LoadFromFile(filename);
}
catch(Exception & e)
{
errmsg = e.Message;
}
catch(...)
{
delete ret;
throw;
}
}
if(errmsg != "")
TVPAddImportantLog(ttstr("(info) Loading configuration file \"") + filename.c_str() +
"\" failed (ignoring) : " + errmsg.c_str());
else
TVPAddImportantLog(ttstr("(info) Loading configuration file \"") + filename.c_str() +
"\" succeeded.");
return ret;
}
示例4: Read
/*=============================================================================
*NAME :TYSIniFile::Read
:
*MODULE :YSIniFiles.cpp
:
*FUNCTION :読み込み処理関数です
:
*PROCESS :・Iniファイル読み込みです。
:
*RETURN : true = 正常終了
:false = エラー終了
:
*PROGRAMMED :Y.Sasai
*HISTORY :
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.10 Y.Sasai Ver.0.90 初期作成
*/
bool TYSIniFile::Read( void )
{
TStringList slist; // 2003.02.10 Y.Sasai Ver.0.90 文字列リスト
int tempi;
TYSIniSection* ysection; // 2003.02.10 Y.Sasai Ver.0.90 セクションクラス
CString sitem;
if ( FileName == "" ) { // 2003.02.10 Y.Sasai Ver.0.90 ファイル名未設定なら…
return ( false ); // 2003.02.10 Y.Sasai Ver.0.90 おわる
} else if ( FileExists( FileName ) == false ) { // 2003.02.10 Y.Sasai Ver.0.90 そのファイルがなかったら…
return ( false ); // 2003.02.10 Y.Sasai Ver.0.90 おわりだ
}
ysection = NULL; // 2003.02.10 Y.Sasai Ver.0.90 セクションクラス初期化だ
if ( slist.LoadFromFile( FileName ) == false ) { // 2003.02.10 Y.Sasai Ver.0.90 ファイル読み込みエラーなら…
return ( false ); // 2003.02.10 Y.Sasai Ver.0.90 エラーだ
}
for ( tempi = 0; tempi < slist.Count; tempi++ ) {
sitem = slist[tempi];
if ( sitem == "" ) { // 2003.02.10 Y.Sasai Ver.0.90 空行なら…
continue; // 2003.02.10 Y.Sasai Ver.0.90 つぎだ
}
if ( SectionCheck( sitem ) == true ) { // 2003.02.10 Y.Sasai Ver.0.90 セクション名なら…
ysection = Add(); // 2003.02.10 Y.Sasai Ver.0.90 セクション追加
ysection->Name = SectionNameGet( sitem ); // 2003.02.10 Y.Sasai Ver.0.90 セクション名設定
} else if ( ysection != NULL ) { // 2003.02.10 Y.Sasai Ver.0.90 セクション設定されているなら…
ysection->Add( sitem ); // 2003.02.10 Y.Sasai Ver.0.90 セクションに追加
}
}
return ( true ); // 2003.02.10 Y.Sasai Ver.0.90 まあいいでしょ
}
示例5: TStringList
void __fastcall TForm1::FileOpen1Accept(TObject *Sender)
{
String a = FileOpen1->Dialog->FileName;
if (a!=""){
// Öffnen
if (ExtractFileExt(a).UpperCase()!=".AD")a=a.SubString(1,a.Length()-ExtractFileExt(a).Length())+".ad";
TStringList *Liste = new TStringList();
Liste->LoadFromFile(a);
Max = StrToInt(Liste->Strings[0]);
Edit1->Text=Liste->Strings[1];
ListBox1->Clear();
Liste->Delete(0);
Liste->Delete(0);
for (int i=0;i<Max;i++){
ListBox1->Items->Add(Liste->Strings[i*67]);
for (int b=0;b<66;b++){
Data[i][b] = StrToInt(Liste->Strings[i*67 + b + 1]);
}
}
ListBox1->ItemIndex=0;
Selected = ListBox1->ItemIndex;
Load_Dat(Selected);
}
}
示例6: ReadConfig
//---------------------------------------------------------------------------
void TRsyncConfigAdapter::ReadConfig(){
if(!FileExists(CONFIG_FILE)){
ShowMessage("Config " CONFIG_FILE " file not found");
return;
}
TStringList* lines = new TStringList();
lines->LoadFromFile(CONFIG_FILE);
TModuleHolder* currentModule = new TModuleHolder();
currentModule->moduleName = GLOBAL_MODULE;
modules->Add(currentModule);
for(int i = 0; i < lines->Count; i++){
AnsiString moduleName = FetchModuleLine(lines->Strings[i]);
if(moduleName.Length() > 0){
currentModule = new TModuleHolder();
modules->Add(currentModule);
currentModule->moduleName = moduleName;
continue;
}
currentModule->nvp->Add(lines->Strings[i]);
}
delete lines;
}
示例7: FormShow
void __fastcall TfMain::FormShow(TObject *Sender)
{
TStringList* sl = new(TStringList);
sl->NameValueSeparator = '=';
TFile f;
if(f.Exists(ExtractFileDir(Application->ExeName) + "\\Library.lb")){
sl->LoadFromFile(GetCurrentDir() + "\\Library.lb");
for(int i = 0; i < sl->Count; i++){
TListItem* Item = lvLib->Items->Add();
Item->Caption = ExtractFileName(sl->Names[i]);
Item->GroupID = 0;
Item->SubItems->Add(sl->Names[i]); //path [0]
TStringList* ss = new(TStringList);
ss->NameValueSeparator = '/';
ss->Add(sl->ValueFromIndex[i]);
Item->SubItems->Add(ss->Names[0]); //bookmark [1]
Item->SubItems->Add(ss->ValueFromIndex[0]); //size [2]
ss->~TStringList();
}
}
sl->Clear();
if(f.Exists(ExtractFileDir(Application->ExeName) + "\\Settings.ini")){
sl->LoadFromFile(GetCurrentDir() + "\\Settings.ini");
leLogin->Text = sl->ValueFromIndex[0];
lePass->Text = sl->ValueFromIndex[1];
if(sl->ValueFromIndex[2] == "1")
cbRememberPass->Checked = true;
else
cbRememberPass->Checked = false;
leServer->Text = sl->ValueFromIndex[3];
}
sl->~TStringList();
}
示例8: OpenFile
void HTMLDocument::OpenFile(const String &filename)
{
TStringList *sl = new TStringList;
FileName = filename;
sl->LoadFromFile(filename);
browser->OpenFile(filename);
rcedit->Lines->Clear();
html = sl->Text;
rcedit->Text = html;
setchanged(false);
delete sl;
}
示例9: THostList
void __fastcall TForm1::FormCreate(TObject *Sender)
{
AnsiString ip;
AnsiString hostname;
int ok;
int time;
TPing pi;
int aa=50;
grLista= new TList;
int pos;
h= new THostList();
TStringList *TempList = new TStringList;
TempList->LoadFromFile("pingowaniet.txt");
for (int i = 0; i < TempList->Count; i++)
{
hostname="";
pos=TempList->Strings[i].AnsiPos(";");
if(pos>0)
{
ip=TempList->Strings[i].SubString(0,pos-1);
hostname=TempList->Strings[i].SubString(pos+1,TempList->Strings[i].Length()-pos);
} else
ip=TempList->Strings[i];
h->AddHost(ip,hostname);
// kreowanie wykresu
gr1=Creategraph(aa);
grLista->Add(gr1);
this->InsertControl(gr1);
aa=aa+127;
};
delete TempList;
incre=0;
pi.Create();
for (int i = 0; i < h->Count(); i++)
{
ip=h->GetHost(i);
pi.Ping(ip,ok,time);
gr1=(TPerformanceGraph *)grLista->Items[i];
if(ok==0)
{
time=9999;
gr1->DataPoint(clRed,150);
} else gr1->DataPoint(clLime,time);
gr1->Update();
h->AddHostPingTime(i,time);
};
if(h->AnyOutTime())
TrayIcon1->IconIndex=1;
else
TrayIcon1->IconIndex=0;
}
示例10: TList
TFastIni::TFastIni(AnsiString FN) :
m_LastSectionIndex(-1)
{
m_Sections = new TList();
TStringList *SL = new TStringList();
if (FileExists(FN)){
SL->LoadFromFile(FN);
}
LoadFromString(SL);
delete SL;
}
示例11: ShowAboutDemoForm
void ShowAboutDemoForm()
{
if (FForm == NULL){
FForm = new TformAboutDemo(Application);
TStringList *ADescription = new TStringList();
try{
ADescription->LoadFromFile(ExtractFilePath(Application->ExeName) + "About.txt");
FForm->Show();
FForm->redDescription->Lines->Text = ADescription->Text;
}
__finally{
delete ADescription;
}
}
示例12: TForm
//---------------------------------------------------------------------------
__fastcall TEnumWinForm::TEnumWinForm(TComponent* Owner)
: TForm(Owner)
{
TStringList *list = new TStringList();
list->LoadFromFile("winmsgs.txt");
AnsiString str;
int k;
for(int i = 0; i < list->Count; i++)
{
str.SetLength(100);
sscanf(list->Strings[i].c_str(),"%s %X\n",str.c_str(),&k);
MsgComboBox->Items->AddObject(str,(TObject *)k);
}
delete list;
MsgComboBox->ItemIndex = 0;
}
示例13: ProcessConfigFile
void __fastcall TfmLauncher::ProcessConfigFile()
{
if (FileExists(ConfigFileName)){
TStringList *ConfigFile = new TStringList();
__try{
ConfigFile->LoadFromFile(ConfigFileName);
RootDirectory = ConfigFile->Values[cRootDirectory];
FileName = ConfigFile->Values[cFileName];
FileName = RemoveTrailingSlash(RootDirectory) + '\\' + RemoveLeadingSlash(FileName);
}
__finally{
delete ConfigFile;
}
}
}
示例14: ScanAndPrint
void ScanAndPrint(seakgOutput *pOutput, UnicodeString fullname) {
TStringList *list = new TStringList();
list->LoadFromFile(fullname);
int nCount = list->Count;
for (int i = 0; i < nCount; i++)
{
UnicodeString str = list->Strings[i];
if (str.Pos(L"class") > 0 && str.Pos("__declspec") > 0) {
UnicodeString code = str + "\r\n";
str = str.Trim();
UnicodeString uuid = "none";
if (str.Pos("\"") > 0)
uuid = str.SubString(str.Pos("\"") + 1, 36);
UnicodeString interfacename = str.SubString(str.Pos("I"), str.Length() - str.Pos("I") + 1);
UnicodeString interfacename2 = getName(str);
bool bStop = false;
int nIncr = 0;
while (bStop == false && i < nCount) {
i++;
str = list->Strings[i];
if (str.Pos("{") > 0) {
nIncr++;
};
if (str.Pos("}") > 0) {
nIncr--;
if(nIncr == 0) bStop = true;
};
code += str + "\n";
};
PrintDoc(pOutput, fullname, interfacename2, uuid, code);
// std::wcout << str.c_str();
};
};
/*std::wcout << "createuuidprojectname: " << << "\r\n";
std::wcout << "projectname: " << projectName.c_str() << "\r\n";
std::wcout << "fullname: " << fullname.c_str() << "\r\n";*/
};
示例15: GetServerIP
String GetServerIP()
{
TStringList *list = new TStringList;
if (FileExists(ExtractFilePath(Application->ExeName) + "\\ip.txt")) {
try {
list->LoadFromFile(ExtractFilePath(Application->ExeName) + "\\ip.txt");
return list->Strings[0];
} catch (...) {
ShowMessage("Ошибка! Не верный ip-адрес сервера.");
delete list;
return "localhost";
}
}
else
return "localhost";
}