[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

text file

I have a combobox with some names
a button below
i want when i select a name from combo and push the button
to create me in C:\Temp a new empty text file with the name from the combo
ex if the selected name is John Mark create C:\Temp\John Mark.txt
Thanks
0
tinti
Asked:
tinti
  • 2
1 Solution
 
rvicentiuCommented:
it's easy...

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TFileStream.Create('C:\TEMP\'+Combobox1.Items[Combobox1.ItemIndex]+'.txt', fmCreate) do Free;
end;
0
 
ThoseBugCommented:
procedure TForm1.Button1Click(Sender: TObject);
var
  FileHandle: Integer;
begin
  FileHandle := FileCreate('c:\temp\'+combobox1.text);
  if FileHandle<0 then showmessage('create file error')
end;
0
 
ThoseBugCommented:
//uupps  add '.txt'

procedure TForm1.Button1Click(Sender: TObject);
var
  FileHandle: Integer;
begin
  FileHandle := FileCreate('c:\temp\'+combobox1.text+'.txt');
  if FileHandle<0 then showmessage('create file error')
end;
end.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now