Другие языки программирования и технологии
2 простых вопроса про Delphi 7
1.Как создать файл txt в папке, где находится exe-шник программы, если там нету такого? 2. Если есть файл, то вписать в него что-то?
Функции по созданиюфайлов посмотри в гугле (Assign и т. д.) , щас точно вспомнить не могу.
чтобы создать в папке приложения можно указать:
либо просто имя файла (без пути) ;
либо использовать extractfilepath(application.exename);
Проверить существование файла:
if fileexist("Имя файла") then
begin
//вписать в него что-то
end;
чтобы создать в папке приложения можно указать:
либо просто имя файла (без пути) ;
либо использовать extractfilepath(application.exename);
Проверить существование файла:
if fileexist("Имя файла") then
begin
//вписать в него что-то
end;
var
fileName : string;
myFile : TextFile;
data : string;
begin
// Try to open a text file for writing to
fileName := 'Test.txt';
AssignFile(myFile, fileName);
ReWrite(myFile);
// Write to the file
Write(myFile, 'Hello World');
// Close the file
CloseFile(myFile);
// Reopen the file in read mode
Reset(myFile);
// Display the file contents
while not Eof(myFile) do
begin
ReadLn(myFile, data);
ShowMessage(data);
end;
// Close the file for the last time
CloseFile(myFile);
// Now see if the file exists
if FileExists(fileName)
then ShowMessage(fileName+' exists OK')
else ShowMessage(fileName+' does not exist');
// Delete the file and look again
DeleteFile(fileName);
if FileExists(fileName)
then ShowMessage(fileName+' still exists!')
else ShowMessage(fileName+' no longer exists');
end;
fileName : string;
myFile : TextFile;
data : string;
begin
// Try to open a text file for writing to
fileName := 'Test.txt';
AssignFile(myFile, fileName);
ReWrite(myFile);
// Write to the file
Write(myFile, 'Hello World');
// Close the file
CloseFile(myFile);
// Reopen the file in read mode
Reset(myFile);
// Display the file contents
while not Eof(myFile) do
begin
ReadLn(myFile, data);
ShowMessage(data);
end;
// Close the file for the last time
CloseFile(myFile);
// Now see if the file exists
if FileExists(fileName)
then ShowMessage(fileName+' exists OK')
else ShowMessage(fileName+' does not exist');
// Delete the file and look again
DeleteFile(fileName);
if FileExists(fileName)
then ShowMessage(fileName+' still exists!')
else ShowMessage(fileName+' no longer exists');
end;
напиши текстовый редактор и не мучайся
если конкретное выполнение задания то вот:
var F:TextFile;
begin
FileName:='myfile.txt';
AssignFile(F,FileName);
if (not fileexists(filename)) then Rewrite(F) else Append(F);
//если нет, то создаем и открываем для записи,
//если есть, добавляем в конец
writeln(F,'какой-то текст');
CloseFile(F);
end;
кажись нигде не ошибся
var F:TextFile;
begin
FileName:='myfile.txt';
AssignFile(F,FileName);
if (not fileexists(filename)) then Rewrite(F) else Append(F);
//если нет, то создаем и открываем для записи,
//если есть, добавляем в конец
writeln(F,'какой-то текст');
CloseFile(F);
end;
кажись нигде не ошибся
1) открываешь блокнот, файл, сохранить как, находишь папку и сохраняешь туда
2) открываешь файл программой, например блокнотом, и вписываешь
2) открываешь файл программой, например блокнотом, и вписываешь
Похожие вопросы
- вопрос по delphi 7.
- Что предпочтительней Delphi 7 или Delphi 2009? И почему?
- Люди у кавонить есть прога на Delphi 7??
- Какой язык лучше учить Delphi 7 или C++ ?
- Язык delphi 7 устарел ??? просто хотел учить delphi 7 но сейчас кто то сказал что устарел
- Несколько вопросов по Delphi
- Какова стоимость? Какова стоимость Borland Delphi 7? И что лучше delphi или lazarus? И почему?
- delphi 7, snake
- Какую версию Delphi лучше использовать? В чём разница XE версии от обычной? XE2,3,4,5,6 или Delphi 7?
- вопрос по delphi