Connecting Tech Pros Worldwide Help | Site Map

Deleting a file

Member
 
Join Date: Nov 2008
Posts: 61
#1: Mar 13 '09
Can't seem to get this to delete the file, ive tried setting the permissions but it still won't delete.

Expand|Select|Wrap|Line Numbers
  1. my $fileName = 'c:\inetpub\wwwroot\guessingGame\guessingGame.csv'; 
  2. unlink($fileName);
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Mar 13 '09

re: Deleting a file


Quote:

Originally Posted by chanshaw View Post

Can't seem to get this to delete the file, ive tried setting the permissions but it still won't delete.

Expand|Select|Wrap|Line Numbers
  1. my $fileName = 'c:\inetpub\wwwroot\guessingGame\guessingGame.csv'; 
  2. unlink($fileName);

Please reply to the threads you start.

Try this, see what $! returns:

Expand|Select|Wrap|Line Numbers
  1. my $fileName = 'c:\inetpub\wwwroot\guessingGame\guessingGame.csv'; 
  2. unlink($fileName) or die "Can't delete file $filename : $!";
There is nothing patently wrong with your usage so either its a wrong path or the file is not closed or some other issue.
Reply