Solution to asp.net File. Delete File deletion failure

Source: Internet
Author: User

Asp tutorial. net file. delete file deletion failure Solution

If (file. exists (server. mapparh ("~ /"+ Filename ))
File. delete (server. mapparh ("~ /"+ Filename ));


The detailed deletion code is as follows:

Protected sub button2_click (byval sender as object, byval e as eventargs) handles button2.click
Dim py as sqlconnection = new sqlconnection ("server = 127.0.0.1; uid = fay; pwd = 19891016; database = studentdb ;")
ACC. open ()
Dim insertstr as string = "delete chengji"
Dim cmd as sqlcommand = new sqlcommand (insertstr, ACC)
Cmd.exe cutenonquery ()
Dim file as fileinfo
Dim filename as string = fileupload1.filename
File = new fileinfo (server. mappath (("~ Newfolder1 ") + filename ))
File. delete ()
ACC. close ()
End sub

If a file cannot be deleted, perform the following operations:

When a function a () is called by a thread, there is file. delete In a (), and "Access to xxx path is denied" appears"

When there is no thread, it is done correctly.


Google has found "add iis_wpg user, iwam _ #### user, aspnet user, isur _ ### user
Required permissions ".

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.