Afternoon!
This might be too simple for a Beginners forum...
I started trying to create a file. It was unsuccessful so I backed up. (Deep breath...exhale...) First things first. Just create the directory to put it in, I thought. Hmph... No luck there, either...
Here's what I started with:
Procedure CreateFile;
const
FileName = 'NewFile.txt';
var
NewDir : string;
begin
NewDir := 'C:\Program Files (x86)\First\Second\';
if GetCurrentDir <> NewDir then
begin
ShowMessage('GetCurrentDir <> NewDir');
if not SetCurrentDir(NewDir) then
begin
ShowMessage('Directory "'+ NewDir + '" does not exist.');
// ChDir('C:\Program Files (x86)\');
{$I-}
mkdir(NewDir);
{$I+}
if IOResult<>0 then
ShowMessage('Cannot create directory : '+NewDir+'.')
else
ShowMessage('Directory created.');
end;
...
I couldn't even change directories...so I commented out the 'ChDir'.
I could not get it to work with or without the 'separators', trying first directory, trying both directories, changing strings, etc.
In my continued readings, I ran across
http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/createdir.html. That example:
If Not DirectoryExists(NewDir) then
If Not CreateDir(NewDir) then
ShowMessage('Failed to create directory!')
else
ShowMessage('Created "NewDir" directory')
I couldn't get that to work either...
I attached the whole unit for those interested.
Care to offer a suggestion?
Thanks!