Creates a new subdirectory.
procedure MkDir(const S: string); overload; procedure MkDir(P: PChar); overload;
MkDir(const AnsiString S); MkDir(const char * P);
System
MkDir creates a new subdirectory with the path specified by string S or P. The last item in the path cannot be an existing file name.
Delphi Examples:
{ The following sample code sets the directory of DirectoryListBox1 to C:\WINDOWS when the form is created. When Button1 is pressed, a subdirectory called mytemp is added to C:\WINDOWS, but note that it is not updated in DirectoryListBox1 until Button2 is pressed and Update is called. Note: A EInOutError will occur if you add a directory that already exists. Also, you must add the new directory to your current path to see the magic happen. } procedure TForm1.Button1Click(Sender: TObject); begin MkDir(Edit1.Text); end; procedure TForm1.Button2Click(Sender: TObject); begin DirectoryListBox1.Update; end; procedure TForm1.FormCreate(Sender: TObject); begin DirectoryListBox1.Directory := 'c:\WINDOWS'; end;
{ This example creates a directory using the path and directory name entered in the text edit. The path is relative to the project directory. Type in the name of an existing directory to induce the error. } procedure TForm1.Button1Click(Sender: TObject); begin {$I-} { Get directory name from TEdit control } MkDir(Edit1.Text); if IOResult <> 0 then MessageDlg('Cannot create directory', mtWarning, [mbOk], 0, mbOk) else MessageDlg('New directory created', mtInformation, [mbOk], 0, mbOk); end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|