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 ".