(SOLVED) C# .NET File.Delete() Not Working.
-
SOLUTION make sure to refresh the folder your checking to see if the files have actually deleted or not. In this case they were (the code works fine), just i wasn't refreshing desktop etc haha, oh well. STUPID QUESTION CONTINUES------------- http://s000.tinyupload.com/index.php?file_id=06162948769787766673[^] The link above is a localized example of my problem. I cannot for the life of me figure out why file.exists or any kind of permission checks don't work! Its like .NET just says oh.. I might delete this, might not, might say i did but actually didn't, or didn't but actually.. didn't, maybe i will if you give me time... but i still wont tell you even if i did or didn't... :confused::mad::confused: so... please save the last few strands of hair on my head! :doh: Thanks! (For ease of viewing: pastebin) or right here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using IWshRuntimeLibrary;namespace test
{
public partial class TestFileDelete : Form
{
Boolean flag = true;public TestFileDelete() { InitializeComponent(); } private void button1\_Click(object sender, EventArgs e) { // disables while running click code this.button1.Enabled = false; // This doesnt seem to do anything either? if (this.button1.Enabled == false) return; // just a either or flag to swtich the end of the shortcut names to see if they are deleted or not with one button int switchnum = (flag) ? 1 : 0; int newnum = (flag) ? 0 : 1; if (flag == true) { flag = false; } else { flag = true; } // this is a bit messy, its taken from my larger project. but this code shows my problem. (in fact my larger project only requires a 200ms timeout, this needs 300..?) String StartMenuProgName = Path.Combine(Environment.GetF