Click here to Skip to main content
15,391,382 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
file is not deleting from this command

file.delete("\\int\specs\upload\sku\23819\Change classification for 985855NM .htm")

even it is not giving any error.

Any help
Updated 25-Jun-10 7:27am

Your file path does not look correct. To verify, are you sure there is a trailing space before the .htm and are there supposed to be two \\s at the front of it. It doesn't appear to have the correct syntax for a file path is my guess.

Have you tried getting the file info for the file so FileInfo f and then f.Delete()

Also paths in C# need to have two \\ in their path name or else put an @ in front of it like @"C:\mypath\file.txt"
Member 7217874 3-Jun-10 11:13am
yes i tried getting file info through object of FileInfo and also tried to delete.
But i am getting file info but not able to detete.....
GregWyatt 3-Jun-10 17:07pm
Try File.Delete(f.FullName) where f is a FileInfo variable. If that doesn't work your application may only have read access to that virtual directory and not full access.
Member 7217874 4-Jun-10 15:53pm
Thanks, problem i got it.

Can we delete the file from any virtual directory by accessing from any other virtual directory?
GregWyatt 4-Jun-10 15:59pm
File Access typically has to be set up by someone with admin privileges on the server. You can specify permissions for folders or virtual directories on the server. So In the past I have had to give some websites access to folders to be able to retrieve or use data from other areas on the machine. You can right click on the folder go to properties, then click on security and add a user to have access to it.
Member 7217874 4-Jun-10 16:04pm
Thanks for helping.....
GregWyatt 4-Jun-10 16:06pm
If you are having a hard time setting the permissions up I can try to help you out. It has a been a little while though since I have had to do it.
Member 7217874 24-Jun-10 11:29am
Actually the deletion is happening on the click of LinkButton which is getting generated through some CSharp code and we are registering its Click event.But nothing is happening.

lnkDelete.Click +=new EventHandler(lnkDelete_Click);

The same code in other form i have written on the click of button and that button is static their. Its working there.

Any Suggestion...
Member 7217874 24-Jun-10 11:31am
and in the onclick event i have written the code for redirecting to some other page that also not working.....
yes their is trailing space before .htm and can you provide me according to you what should be the correct path.
or can you modify the exsisting path..

GregWyatt 2-Jun-10 16:31pm
are you using with C# VB or something else and is the file you are trying to delete within the project folder or is it somewhere on the C,D, E drive somewhere?
Member 7217874 2-Jun-10 16:35pm
actually the file which i am going to delete it is in the virtual directory of some other system and i am using with c# 2003.
GregWyatt 2-Jun-10 16:42pm
For clarification on what you are trying to do. Is this what you mean?
Run the app or site on one server or machine and try to delete a file in a virtual directory on another machine?
Member 7217874 2-Jun-10 16:44pm
yes. first i get the file from that virtual directory and after that i am deleting the file from that virtual directory on another machine.
Donsw 2-Jun-10 16:59pm
do you have the right permissions to delete the file?
Member 7217874 2-Jun-10 17:02pm
i am able to access the file from my app and able to open the file only problem is while deleting. its actually not giving me any exception while deleting the file but whn i am again visting that page its not actually deleted.
GregWyatt 2-Jun-10 17:04pm
is it wrapped inside of a try catch where you could view the exception if there is one.
Member 7217874 3-Jun-10 7:56am
yes i wrapped inside try catch but no exception is coming.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900