File readwrite

zhaozj2021-02-16  54

/ Write file, the data set is a, b, c three fields in the clientDataSet1

IF (ClientDataSet1-> iSempty ()) {ShowMessage ("files can be written!"); return;} Savedialog1-> Title = "Select path name:"; Savedialog1-> filename = "Module Name" Date ). Formatstring ("YYYYMMDD"); Savedialog1-> defaultExt = "txt"; Savedialog1-> Filter = "text file (* .txt) | All files (*. *) | (*. * ) "; Clientdatanet1-> first (); while (! ClientDataSet1-> EOF) {file * fp = fopen (Savedialog1-> FieldName," WT "); FPRINTF (FP,"% S / T ", clientDataSet1-> FieldByname ("a") -> asstring.trim ()); fprintf (fp, "% s / t", clientDataSet1-> fieldByname ("b") -> asstring.trim ()); fprintf (fp, "% s / N ", ClientDataSet1-> FieldByname (" c ") -> asstring.trim ()); clientDataSet1-> next ();} fclose (fp); showMessage (" Write file success! ");

转载请注明原文地址:https://www.9cbs.com/read-24277.html

New Post(0)