怎样删除文件?

internetibm 2002-01-27 02:53:36
有这个一个文件位于c:\111,我想删除/这语名是怎样的?
...全文
83 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wind0521 2002-01-28
  • 打赏
  • 举报
回复
用unlink函数就可以了!
jinandsun 2002-01-28
  • 打赏
  • 举报
回复

system ("del c:\111\文件")||die "can't del :$!";

不就可以了~
我有点没理解你后面的那句话~
nan1nan1 2002-01-27
  • 打赏
  • 举报
回复
老大,没搞错吧……

用unlink
$ touch test

$ perl -e "unlink('/test');"

$ ls test
ls: test: No such file or directory


unlink LIST

unlink

Deletes a list of files. Returns the number of files successfully deleted.
$cnt = unlink 'a', 'b', 'c';
unlink @goners;
unlink <*.bak>;
Note: unlink will not delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Use rmdir instead.

If LIST is omitted, uses $_.



pampa 2002-01-27
  • 打赏
  • 举报
回复
用api函数 DeleteFile,
具体可以看msdn上的用法:
DeleteFile
This function deletes an existing file from a file system. It can also delete an unmounted database volume. A remote application interface (RAPI) version of this function exists, and it is named CeDeleteFile.

BOOL DeleteFile(
LPCTSTR lpFileName );
Parameters
lpFileName
[in] Pointer to a null-terminated string that specifies the file or database volume to be deleted.
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks
If an application attempts to delete a file that does not exist, the DeleteFile function fails.

Use the RemoveDirectory function to delete a directory.

The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file.

To close an open file handle, use the CloseHandle function.

To unmount a database volume, use the CeUnmountDBVol function.

2,203

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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