Delete Files File.Delete() WebApp

I wrote a web app that delete files off  servers. The web app works fines when compiled and ran off Visual Studio 2005.  But when trying to run off of IIS it cannot see the files on that server or another server. Visual Studio 2005 is on the same machine IIS is running on. Is there a setting on IIS that I am missing? Please help. Thanks!

 

-Nelson

0
nelsonlowe
3/25/2009 5:20:04 PM
asp.net.vs2005-webapp-projects 1239 articles. 0 followers. Follow

5 Replies
1111 Views

Similar Articles

[PageSpeed] 51
Get it on Google Play
Get it on Apple App Store

Hi,

try checking the path of the file that you are assiging to delete method.


Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution.
Mohammad Hussain
http://mohdhussain.blogspot.com/
0
mohd786hussain
3/26/2009 4:43:01 AM

Hi Friend,

Try to use the Following code.

 public void DeleteFiles()
    {
        DirectoryInfo Folder = new DirectoryInfo(Server.MapPath(VirtualPath));
        FileInfo[] file = Folder.GetFiles();
        
        foreach (FileInfo frie in file)
        {    
            frie.Delete();
        }
    }


Enjoy Smile

Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.

Regards,
Bhaumik
0
vora_bhaumik
3/26/2009 5:18:53 AM

Thanks. I will try it right now.

0
nelsonlowe
3/26/2009 7:49:38 PM

 Then Do my post as Mark As Answer... Smile


Enjoy Smile

Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.

Regards,
Bhaumik
0
vora_bhaumik
3/27/2009 3:43:00 AM

Sorry that wasn't the answer but thanks for the help. After looking around I found the answer.

 I needed to add the following code to web.config

          <identity impersonate="true" />

0
nelsonlowe
3/27/2009 4:30:23 AM
Reply:

Web resources about - Delete Files File.Delete() WebApp - asp.net.vs2005-webapp-projects

Control-Alt-Delete - Wikipedia, the free encyclopedia
or in DOS , Windows 3.0 and earlier version of Windows or OS/2 , the key combination reboots the computer. Starting with Windows 3.1 , the command ...

Free Speech Group Angered After Facebook Deletes Post On Syria
Facebook issued an apology after mistakenly deleting a post from free speech group Article 19 about human rights abuses in Syria . continued… ...

Facebook brings activity log to mobile devices so users can delete stories and check privacy settings ...
... added an activity log feature to some mobile devices, allowing users to see all their recent activity, verify their privacy settings and delete ...

Tweets MPs Delete (@deletedbyMPs) on Twitter
Sign in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Tweets MPs Delete @ deletedbyMPs ...

Pixar Animation Studios : Did Pixar accidentally delete Toy Story 2 during production?
Answer (1 of 2): Hi everyone, I'm the Oren Jacob in the video. Hopefully I can offer some first person color commentary about the video above ...

Flic – Delete & Manage Camera Roll Photos on the App Store on iTunes
Get Flic – Delete & Manage Camera Roll Photos on the App Store. See screenshots and ratings, and read customer reviews.

Delete - Flickr - Photo Sharing!
Delete buttons on an Apple keyboard. (This image is free to use on your blog or website. If you do so, please credit Cari McGee with a link to ...

Viber now lets you attach files, delete messages and more
... and public chat forwarding in late September , the app keeps growing. In an update today, Nov. 24, Viber users can now attach files, delete ...

Anonymous aims to delete the Islamic State 'virus' from the web, and wants your help
... spread their ideals of terror among the young and impressionable. The aim of #OpISIS is to shut down these channels where possible, and "delete ...

Man sues Apple after retail employee deletes years worth of photos
Deric White, a 68 year-old man from the UK, is suing Apple for approximately $7,500 after an Apple employee at the company's Regent Street store ...

Resources last updated: 12/19/2015 9:53:06 AM