Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 18.07.07 10:54 
Hallo,

weiß jemand wie man nach Dateien mit einer speziellen Dateiendung suchen kann? In Delphi geht das mit Findfirst, Findnext, usw., aber wie geht das in C#???

Hat irgendjemand Ahnung? :gruebel:


Moderiert von user profile iconChristian S.: Topic aus C# - Die Sprache verschoben am Mi 18.07.2007 um 10:57
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 18.07.07 10:59 
Hallo!

Schau Dir mal die Überladungen von Directory.GetFiles an, da gibt's auch eine mit Filter.

Grüße
Christian

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

WinXP
Delphi 2007
BeitragVerfasst: Mi 18.07.07 11:39 
Ich habe mich jetzt mal ein bisschen damit beschäftigt, aber es klappt noch nicht so richtig.
Das ist alles was ich bisher habe:
ausblenden volle Höhe 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:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections.Specialized;

namespace DeviceApplication3
{

    public partial class Form1 : Form
    {
        string ss;
        public Form1()
        {
            InitializeComponent();
        }

        private void menuItem3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void menuItem4_Click(object sender, EventArgs e)
        {
            MessageBox.Show(ss);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            ss = Directory.GetFiles("Storage Card");

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}

Jetzt erhalte ich beim Kompilieren immer einen Fehler:
ausblenden Quelltext
1:
Eine implizite Konvertierung vom Typ "string[]" in "string" ist nicht möglich.					

ich vermute, das er eine Variable vom Typ stringlist möchte, aber wie deklariert man die in C#?
Sorry für die dummen Fragen, aber ich habe erst mit C# angefangen
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 18.07.07 11:45 
Schau Dir mal die C#-Doku zu Arrays an. Das sind Grundlagen der Sprache, die man schon beherrschen sollte.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Mi 18.07.07 19:24 
Ich hab auch erst mit C# angefangen, sollte eigentlich so gehen, habs aber nicht ausprobiert:
ausblenden C#-Quelltext
1:
ss = Directory.GetFiles(new string[] { "Storage Card" }););					

So sollte es auf alle Fälle gehen:
ausblenden C#-Quelltext
1:
2:
string[] sa = new string[] { "Storage Card " };
ss = Directory.GetFiles(sa);

user profile iconChristian S. hat folgendes geschrieben:
Schau Dir mal die C#-Doku zu Arrays an. Das sind Grundlagen der Sprache, die man schon beherrschen sollte.

Sehr empfehlenswert: dies, speziell das.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 18.07.07 20:11 
GetFiles liefert ein Array zurück, es erwartet kein Array als Parameter

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