Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello everyone,

I made a website in which administrator has each and every privileges i.e. for deleting user etc. and he has also the privileges for deleting pages(.aspx) at run time.

Now what i need is , i need to list all pages name in gridview if one of the pages is selected by admin and he says delete then that page should be permanently removed from the website.

How do i implement that listing all pages part and deletion part of the page...

Please help me out...

Thanks & Regards,
Krunal Panchal
Posted
Comments
BobJanova 4-Apr-11 7:01am    
Are you sure you want to permanently delete the files? Disabling them seems like a better solution.

The admin probably already has FTP access which he can use to delete files, as well as chmod 400 or whatever the Windows equivalent is so they can't be accessed over the Internet.

To list them:
string[] files = Directory.GetFiles(path, "*.aspx");
You can then display them in your prefered way.
To delete them:
File.Delete(files[0]);
Will delete the first file in the list.
 
Share this answer
 
Comments
[no name] 3-Apr-11 6:04am    
Hi,
You are correct buddy, your solution worked on my local machine...
But i need it on server like i have the ip address of that server and username and password also...
so how do i make it for the server??

Please help me :(

Thanks & Regards,
Krunal panchal
You need to take care of security stuff here, your application will run on client machines under asp.net machine account, on servers w3wp.exe worker process, just check on the server whether this account has sufficient previleges to delete the files, check the ACLs on the file system of the server. add necessary rights to the folder.

if your network doesn't allow you to have your worker process to delete the files, you need to ask a previleged account for the folder you are trying to have the delete functionality, once you have the account, then have a web.config file in the folder to impersenate the request using that account and have the delete operation working.
 
Share this answer
 
Comments
[no name] 4-Apr-11 3:09am    
Hello,
thanks for your kind response, but can you explain me how to implement it,as i have not done this before.

Please help me out.

Thanks & Regards,
Krunal Panchal

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