Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. (SOLVED) C# .NET File.Delete() Not Working.

(SOLVED) C# .NET File.Delete() Not Working.

Scheduled Pinned Locked Moved C#
csharpquestionphpdatabaselinq
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    uniflare
    wrote on last edited by
    #1

    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
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups