File.Delete

Y

yosi maurer

I use File.Delete(path) in my web application.

If the file for deletion is opened i expect to receive the exception:
"Additional information: The process cannot access the file [path]
because it is being used by another process."

The problem is that when the file is opened by a client machine then
the server that runs the code fails to delete but does not throw any
exception.

In this case i have no idea if the delete action succeeded or not.

Ofcourse i can use File.Exists after the delete action to check the
success.

I wanted to know if there is a more elegant solution for this problem.
 
G

Guest

I'm experiancing the same issue. Knowing that it should return an exception
doesn't help with the result that it does not.

Is anyone aware why this happens? Is it related to the version of ASP.NET,
IIS, Windows? Is it some configuration parameter? Is it some issue related to
the client.

What can be done to get the proper exception response from a File.Delete on
systems that are not properly generating an exception.

The environment that I have noticed the problem with is:

Microsooft Windows Server 2003 Standard Edition
IIS V6.0
Microsoft.Net Framework v1.1.4322

Clients are both Windows 2000 and XP

Any ideas or recomendations on how to get proper exceptions from clients
would be greatly appreciated. More details are easly produced if anyone needs
them. It is very easy for me to reproduce this problem on the above
environement.

I would give a warning I have attempted to use File.Exists in this case as
another way to detect if the delete fails and have ran into infrequent race
conditions where the File.Exists will falsly reporting that the File.Exists
after the File.Delete.

Matthew


Eran Kampf said:
According to the MSDN
docs(http://msdn.microsoft.com/library/d...ef/html/frlrfSystemIOFileClassDeleteTopic.asp)
an IOException should be thrown....

--
Eran Kampf
http://www.ekampf.com/blog
http://www.ekampf.com

yosi maurer said:
I use File.Delete(path) in my web application.

If the file for deletion is opened i expect to receive the exception:
"Additional information: The process cannot access the file [path]
because it is being used by another process."

The problem is that when the file is opened by a client machine then
the server that runs the code fails to delete but does not throw any
exception.

In this case i have no idea if the delete action succeeded or not.

Ofcourse i can use File.Exists after the delete action to check the
success.

I wanted to know if there is a more elegant solution for this problem.
 
G

Guest

I'm experiancing the same issue. Knowing that it should return an exception
doesn't help with the result that it does not.

Is anyone aware why this happens? Is it related to the version of ASP.NET,
IIS, Windows? Is it some configuration parameter? Is it some issue related to
the client.

What can be done to get the proper exception response from a File.Delete on
systems that are not properly generating an exception.

The environment that I have noticed the problem with is:

Microsooft Windows Server 2003 Standard Edition
IIS V6.0
Microsoft.Net Framework v1.1.4322

Clients are both Windows 2000 and XP

Any ideas or recomendations on how to get proper exceptions from clients
would be greatly appreciated. More details are easly produced if anyone needs
them. It is very easy for me to reproduce this problem on the above
environement.

I would give a warning I have attempted to use File.Exists in this case as
another way to detect if the delete fails and have ran into infrequent race
conditions where the File.Exists will falsly reporting that the File.Exists
after the File.Delete.

Matthew

Eran Kampf said:
According to the MSDN
docs(http://msdn.microsoft.com/library/d...ef/html/frlrfSystemIOFileClassDeleteTopic.asp)
an IOException should be thrown....

--
Eran Kampf
http://www.ekampf.com/blog
http://www.ekampf.com

yosi maurer said:
I use File.Delete(path) in my web application.

If the file for deletion is opened i expect to receive the exception:
"Additional information: The process cannot access the file [path]
because it is being used by another process."

The problem is that when the file is opened by a client machine then
the server that runs the code fails to delete but does not throw any
exception.

In this case i have no idea if the delete action succeeded or not.

Ofcourse i can use File.Exists after the delete action to check the
success.

I wanted to know if there is a more elegant solution for this problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top