Though it is not in special folder I don't know how to find it. In fact I want to delete a file that my application creates in AppData.
The way I figured it might work is move it to the recycle bin and then try to delete it. The application is Console application in .Net 4.5
Asked
Active
Viewed 1,325 times
1

Burak Karakuş
- 1,368
- 5
- 20
- 43

user6470140
- 89
- 1
- 1
- 8
-
1You don't need to explicitly move it to the Recycle Bin, you can use File.Delete to clean it up: https://msdn.microsoft.com/en-us/library/system.io.file.delete(v=vs.110).aspx – Ryan Intravia Jun 17 '16 at 14:38
-
I forgot to mention that when I try to delete it while it is in AppData it give an access denied exception – user6470140 Jun 17 '16 at 14:40
-
Permissions/readonly attribute. – ManoDestra Jun 17 '16 at 14:41
-
2This is very clearly an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). You’re trying to delete a file but you do not have access to do that, so you attempt to move it to the recycle bin instead and deleting it from there. You should ask how to delete that file properly instead of how to find the recycle bin (which will not solve your permission problem at all). – poke Jun 17 '16 at 14:42
2 Answers
6
System.IO.File.Delete(string path);
will delete a file permanently, bypassing the recycle bin.
I forgot to mention that when I try to delete it while it is in AppData it give an access denied exception
If you're using %AppData%
for temporary files, make sure you get a temporary directory within it by using System.IO.Path.GetTempPath()
otherwise you're likely to get permission related errors

Neirid
- 363
- 2
- 8
-
I get a access denied exception while trying to delete it that way while the files are in AppData – user6470140 Jun 17 '16 at 14:42
-
1
-
I've updated my answer; but make sure you're using a temporary folder your program has access to: `System.IO.Path.GetTempPath()` should do the trick – Neirid Jun 17 '16 at 14:43
0
Something like this should do the work for you: start shell:RecycleBinFolder

Burak Karakuş
- 1,368
- 5
- 20
- 43