Waiting for a file deletion to continue

G

Guest

I have a web application that allows a user to manage files on the server.
On the page is a counter that tells them how many files are in their folder.
When you delete a file from the folder using ASP.NET, it seems to send a
command off to delete the file and keeps processing the page... the page
reloads, but the file count of the folder doesn't change because it seems
that the page rendering is faster than the file deletion.

Is there any way to get around this?
 
G

Guest

hi
try to make sleep thread for a little time before deleting the file.
include System.Threading and add in you code
Thread.Sleep(100);

Or Just keep in viewstate the last number of files before delete and just
decrement with 1 your file number.

Cheers
 
G

Guest

I use the FileInfo object to delete the file, they are all stored in a
FileInfo[] array.

I get the count by using the IMessages interface, since these are email
messages and I have to read the headers for each file... so I use the
IMessages.Count property.
 
E

Eliyahu Goldin

Deleting with FileInfo is fine, it should delete file immediatly. I am not
familiar with IMessages. If you use something like DirectoryInfo.GetFiles()
you should get the right result.

Eliyahu

Diggler said:
I use the FileInfo object to delete the file, they are all stored in a
FileInfo[] array.

I get the count by using the IMessages interface, since these are email
messages and I have to read the headers for each file... so I use the
IMessages.Count property.

Eliyahu Goldin said:
How do you delete files and how do you update the count?

Eliyahu
 
G

Guest

No, that didn't work. I call two different methods...

DeleteFiles() and then
PopulateDataGrid().

DeleteFiles runs first, deletes the file(s) and I changed the code in
PopulateDataGrid to read the directory using DirectoryInfo.GetFiles(). I
think the code is running faster than the delete.

Eliyahu Goldin said:
Deleting with FileInfo is fine, it should delete file immediatly. I am not
familiar with IMessages. If you use something like DirectoryInfo.GetFiles()
you should get the right result.

Eliyahu

Diggler said:
I use the FileInfo object to delete the file, they are all stored in a
FileInfo[] array.

I get the count by using the IMessages interface, since these are email
messages and I have to read the headers for each file... so I use the
IMessages.Count property.

Eliyahu Goldin said:
How do you delete files and how do you update the count?

Eliyahu

I have a web application that allows a user to manage files on the server.
On the page is a counter that tells them how many files are in their
folder.
When you delete a file from the folder using ASP.NET, it seems to send a
command off to delete the file and keeps processing the page... the page
reloads, but the file count of the folder doesn't change because it seems
that the page rendering is faster than the file deletion.

Is there any way to get around this?
 
E

Eliyahu Goldin

Very strange. Are you sure the delete works in the first place?

Eliyahu

Diggler said:
No, that didn't work. I call two different methods...

DeleteFiles() and then
PopulateDataGrid().

DeleteFiles runs first, deletes the file(s) and I changed the code in
PopulateDataGrid to read the directory using DirectoryInfo.GetFiles(). I
think the code is running faster than the delete.

Eliyahu Goldin said:
Deleting with FileInfo is fine, it should delete file immediatly. I am not
familiar with IMessages. If you use something like DirectoryInfo.GetFiles()
you should get the right result.

Eliyahu

Diggler said:
I use the FileInfo object to delete the file, they are all stored in a
FileInfo[] array.

I get the count by using the IMessages interface, since these are email
messages and I have to read the headers for each file... so I use the
IMessages.Count property.

:

How do you delete files and how do you update the count?

Eliyahu

I have a web application that allows a user to manage files on the server.
On the page is a counter that tells them how many files are in their
folder.
When you delete a file from the folder using ASP.NET, it seems to send a
command off to delete the file and keeps processing the page...
the
page
reloads, but the file count of the folder doesn't change because
it
seems
that the page rendering is faster than the file deletion.

Is there any way to get around this?
 
G

Guest

I am abolutely sure. I keep the folder containing the file open while
deleting, and watch the file disappear. The page usually displays before the
file disappears. I theorize that the framework sends a message to the
operating system to 'delete this file' then returns immediately, allowing the
OS to take care of the actual delete.

Eliyahu Goldin said:
Very strange. Are you sure the delete works in the first place?

Eliyahu

Diggler said:
No, that didn't work. I call two different methods...

DeleteFiles() and then
PopulateDataGrid().

DeleteFiles runs first, deletes the file(s) and I changed the code in
PopulateDataGrid to read the directory using DirectoryInfo.GetFiles(). I
think the code is running faster than the delete.

Eliyahu Goldin said:
Deleting with FileInfo is fine, it should delete file immediatly. I am not
familiar with IMessages. If you use something like DirectoryInfo.GetFiles()
you should get the right result.

Eliyahu

I use the FileInfo object to delete the file, they are all stored in a
FileInfo[] array.

I get the count by using the IMessages interface, since these are email
messages and I have to read the headers for each file... so I use the
IMessages.Count property.

:

How do you delete files and how do you update the count?

Eliyahu

I have a web application that allows a user to manage files on the
server.
On the page is a counter that tells them how many files are in their
folder.
When you delete a file from the folder using ASP.NET, it seems to
send a
command off to delete the file and keeps processing the page... the
page
reloads, but the file count of the folder doesn't change because it
seems
that the page rendering is faster than the file deletion.

Is there any way to get around this?
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top