Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a problem, i want to delete a file through code which is located under read only folder at server. i need to change the folder setting temporarily which allows me to delete the file in it.

Or is their any other way i can achieve this?

Thank you.
Posted

See here[^].
 
Share this answer
 
Comments
deepakwaje 16-Nov-10 1:24am    
Thanx Abhinav,
But the issue is the folder containing the file which i need to delete, this folder is readonly
the container folder property i need to change
C#
string filePath =Server.MapPath("file.txt");
System.IO.File.SetAttributes(filePath,System.IO.File.GetAttributes(filePath) ^ System.IO.FileAttributes.ReadOnly);
System.IO.File.Delete(filePath);
 
Share this answer
 
Comments
deepakwaje 16-Nov-10 2:01am    
Thanx,
But the issue is the folder containing the file which i need to delete, this folder is readonly
the container folder property i need to change

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