Autor Beitrag
KWR1995
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Win 7
Delphi 4, C# Express
BeitragVerfasst: Di 11.03.14 19:01 
Hi,
ich habe das Problem, dass ich mir nicht erklären kann warum er das Verzeichniss nicht löschen kann.
wenn ich auf den Button drücke gibt er nur folgene Fehlermeldung aus:
"Eine nicht behandelte Ausnahme des Typs "System.UnauthorizedAccessException" ist in mscorlib.dll aufgetreten.

Zusätzliche Informationen: Der Zugriff auf den Pfad "map.xml" wurde verweigert."

Vllt. kann mir ja einer von Euch sagen wo der Fehler liegt :D

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication21
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string user = textBox1.Text;
            
            if (System.IO.Directory.Exists(@"C:\users\" + @user + "\\Appdata\\Roaming\\Command & Conquer 3 Tiberium Wars") == true)
            {
                System.IO.Directory.Delete(@"C:\users\" + @user + "\\Appdata\\Roaming\\Command & Conquer 3 Tiberium Wars"true);
            }
        }
    }
}


MfG.: KWR


Moderiert von user profile iconChristian S.: Topic aus WinForms verschoben am Di 11.03.2014 um 18:38
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 11.03.14 19:37 
Kannst Du es im Explorer ohne Fehlermeldung löschen?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
KWR1995 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Win 7
Delphi 4, C# Express
BeitragVerfasst: Di 11.03.14 19:46 
Jap, kann ich Problem los löschen.
KWR1995 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Win 7
Delphi 4, C# Express
BeitragVerfasst: Di 11.03.14 19:51 
Ich habe gerade mal getestet ob er die Fehlermeldung ebenfalls gibt, wenn der Ordner nicht vorhanden ist.
Wobei es zu keiner Fehlermeldung kam, daher muss es anscheinend am eigentlichen Löschvorgang liegen.
KWR1995 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Win 7
Delphi 4, C# Express
BeitragVerfasst: Di 11.03.14 20:07 
Hab tatsächlich noch ne Lösung gefunden:
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;


namespace WindowsFormsApplication21
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string user = textBox1.Text;
            
           string d = (@"C:\users\" + @user + "\\Appdata\\Roaming\\Command & Conquer 3 Tiberium Wars");


           if (System.IO.Directory.Exists(d))

               System.IO.Directory.Delete(d, true);
        }
    }
}


Trotzdem Danke :lol:

MfG.: KWR
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 11.03.14 21:05 
Dann ist da vorher was anderes falsch gelaufen, die Quelltexte tun genau das gleiche.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".