![]() |
![]() |
|
Samples
The following are a few simple samples to show how various operations can easily be performed using the X Library. Samples
Download, modify, encrypt, and store to disk
XString sxData; //Declare variable sxData.DownloadFile("http://www.brightbug.com/index.html"); //Download index.html from brightbug.com. sxData.ReplaceNoCase("BrightBug","guBthgirB"); //Replace BrightBug with the reverse in the string. sxData.Encrypt("MyEncryptPasswordKey"); //Encrypt the HTML page with your key. sxData.WriteFile("c:\\XLibrarySample\\EncyptedFile.dat"); //Write the encrypted file to disk sxData.Decrypt("MyEncryptPasswordKey"); //Decrypt the HTML page with your key. sxData.WriteFile("c:\\XLibrarySample\\index.html"); //Write the plain html to disk.
Read file tree, build file with each exe file's created time, compress,
and write to disk
XString sxData; //Declare some variables XString sxFileName; XString sxCreateTime; XStringArray sxaFileList; sxaFileList.GetFileList("c:\\"); //Get the filenames on the C: drive unsigned int uiLen=sxaFileList.GetLength(); //Get number of files for(unsigned int ui=0;ui<uiLen;ui++){ //For each file sxFileName=sxaFileList[ui]; //Copy filename if(sxFileName.EndsWithNoCase(".exe")==true){ //If the file ends with .exe without regard to case. sxCreateTime.GetFileCreateTime(sxFileName,"MMMM D, YYYY - hh:mm:ss tt"); //Get the file time in my format. sxData.FormatAppend("%s\r\n\t%s\r\n",(const char*)sxFileName,(const char*)sxCreateTime); //Append the data. } } sxData.Compress(); //Compress our list. sxData.WriteFile("c:\\XLibrarySample\\ExeListCompressed.dat"); //Write our list to our directory. sxData.Decompress(); //Decompress our compressed list. sxData.WriteFile("c:\\XLibrarySample\\ExeList.txt"); //Write the plain text list to our directory. | |||||||