怎样创建隐藏的TXT文件?

jog81 2003-04-09 08:56:40
我想在程序运行过程中生成一个隐藏的TXT文件,这样应该可以实现吧?
应该怎么做呢?
我需要在程序运行之后将它删除!
...全文
102 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaojinghui 2003-04-09
  • 打赏
  • 举报
回复
FileSetAttr('c:/电话号码.txt',faHidden)
zhaojinghui 2003-04-09
  • 打赏
  • 举报
回复
先创建些文件
然后设置它的属性!
可以参考如下:
procedure TFMForm.Properties1Click(Sender: TObject);
var
Attributes, NewAttributes: Word;
begin
with FileAttrForm do
begin
FileDirName.Caption := FileList.Items[FileList.ItemIndex];
{ set box caption }
PathName.Caption := FileList.Directory;
{ show directory name }
ChangeDate.Caption :=
DateTimeToStr(FileDateToDateTime(FileAge(FileList.FileName)));
Attributes := FileGetAttr(FileDirName.Caption);
{ read file attributes }
ReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;
Archive.Checked := (Attributes and faArchive) = faArchive;
System.Checked := (Attributes and faSysFile) = faSysFile;
Hidden.Checked := (Attributes and faHidden) = faHidden;
if ShowModal <> id_Cancel then { execute dialog box }
begin
NewAttributes := Attributes;
{ start with original attributes }
if ReadOnly.Checked then
NewAttributes := NewAttributes or faReadOnly
else
NewAttributes := NewAttributes andnot faReadOnly;
if Archive.Checked then
NewAttributes := NewAttributes or faArchive
else
NewAttributes := NewAttributes andnot faArchive;
if System.Checked then
NewAttributes := NewAttributes or faSysFile
else
NewAttributes := NewAttributes andnot faSysFile;
if Hidden.Checked then
NewAttributes := NewAttributes or faHidden
else
NewAttributes := NewAttributes andnot faHidden;
if NewAttributes <> Attributes then { if anything changed... }
FileSetAttr(FileDirName.Caption, NewAttributes);
{ ...write the new values }
end;
end;
end;
idilent 2003-04-09
  • 打赏
  • 举报
回复
memo1.Lines.SaveToFile('map.txt');
FileSetAttr('map.txt',faHidden);

jog81 2003-04-09
  • 打赏
  • 举报
回复
我是这样想的,把memo1里的文件保存在new.txt中,
memo1.Lines.SaveToFile('map.txt');
但是同时把map设置成隐藏我就不会了!

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧