Click here to Skip to main content
15,886,075 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
Posted
Updated 25-Jun-10 7:27am
v2

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"
 
Share this answer
 
v2
Comments
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    
OK.......)
Thanks for helping.....
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..

Thanks..
 
Share this answer
 
Comments
GregWyatt 2-Jun-10 16:31pm    
are you using asp.net 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 asp.net 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 asp.net 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?

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