Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
//----------------------------------------------------
void __fastcall TMainForm::DeleteAllUserFilesBitBtnClick(
TObject *Sender)
{
AnsiString ThisDataPath;
if (DataPath[DataPath.Length()] == '\\')
ThisDataPath=DataPath+MyObjectName;
else
ThisDataPath=DataPath+"\\"+MyObjectName;
if (DirectoryExists(ThisDataPath))
{
TFileListBox *TempFLB = new TFileListBox(this);
TempFLB->Parent = MyForm;
TempFLB->Visible = false;
// load the filenames:
TempFLB->Directory = ThisDataPath+"\\MyFolder\\";
TempFLB->Items->SaveToFile(
ThisDataPath+"\\Intermediate.txt");
TMemo *TempMemo = new TMemo(this);
TempMemo->Parent = MyForm;
TempMemo->Visible = false;
TempMemo->Lines->LoadFromFile(
ThisDataPath+"\\Intermediate.txt");
int interm_max = TempMemo->Lines->Count;
AnsiString UserDirFileName;
AnsiString Ext;
AnsiString IntermediateFileName;
AnsiString UserDirFileNameCompletePath;
for (int imx = 0; imx < interm_max; imx++)
{
UserDirFileName = TempMemo->Lines->Strings[imx];
UserDirFileNameCompletePath =
ThisDataPath+"\\MyFolder\\"+UserDirFileName;
Ext = ExtractFileExt(UserDirFileName);
// this was changed to let the user keep the wanted (e.g.
// archived) files in the directory, also checking
// DOS formatted names MY1 and MY2)
if ( ( Ext == ".my1") ||
( Ext == ".My1") ||
( Ext == ".MY1") ||
( Ext == ".my2") ||
( Ext == ".My2") ||
( Ext == ".MY2") ||
( Ext == ".my3") )
{
DeleteFile(UserDirFileNameCompletePath);
}
} // end for (int imx = 0; imx < interm_max; imx++)
// DO NOT FORGET:
delete TempMemo;
delete TempFLB;
}//end if (DirectoryExists(ThisDataPath)
else
{
ShowMessage("No files (*.my1, *.my2 or *.my3) found!");
}
} // end of DeleteAllUserFiles(...)
//---------------------------------------------------------------------------
//To back up before delete (but delete the last back up),
// when necessary:
IntermediateFileName = ChangeFileExt(
UserDirFileNameCompletePath, ".bak");
if (FileExists(IntermediateFileName))
{
DeleteFile(IntermediateFileName);
}
RenameFile(UserDirFileNameCompletePath,
IntermediateFileName);
void __fastcall TOptionsDlg::EmptyDir(AnsiString Directory)
{
TSearchRec sr;
if(FindFirst(Directory+"\\*.*"
, faAnyFile | faDirectory, sr) == 0)
{
do
{
AnsiString CurFile = sr.Name;
if(CurFile != "." && CurFile != ".."
&& CurFile != "...")
{
if(DirectoryExists(Directory+"\\"+CurFile))
{
EmptyDir(Directory+"\\"+CurFile);
RemoveDir(Directory+"\\"+CurFile);
}
if(FileExists(Directory+"\\"+CurFile))
DeleteFile(Directory+"\\"+CurFile);
}
}
while(FindNext(sr) == 0);
FindClose(sr);
}
}