Autor Beitrag
matze94
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 18.03.10 06:52 
hallo ich bin neu hier aber ich hab da mal ne frage
also ich hab ein kleines Programm für meinen usb-stick
funktioniert auch aber nur mit normalen pfadangaben
wenn ich den jetzt wo anders ansteck erscheint wieder
ein ganz anderer das lässt sich nicht vermeiden
kann ich den Befehl

ausblenden C#-Quelltext
1:
System.Diagnostics.Process.Start("explorer"@"B:\DATA");					


auch relativ setzen, wen ja wie?

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
Moderiert von user profile iconChristian S.: Topic aus C# - Die Sprache verschoben am Do 18.03.2010 um 09:29
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 18.03.10 07:13 
Hallo und :welcome:

Du kannst einfach das Verzeichnis deiner Exe benutzen. :idea:
Wenn es ein Unterverzeichnis sein soll, kannst du die Pfade mit Path.Combine zusammenfügen.
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Fr 19.03.10 20:17 
äh wo sol ich das ding hinpacken und was soll ich dan als pfad bei explorer reinschreiben?

bei mir sieht es im moment ziemlich wild aus


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static string StartupPath { get; }
        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("explorer"@"B:\DATA");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            System.Diagnostics.Process.Start("explorer"@"");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("PStart.exe","");


Moderiert von user profile iconChristian S.: Quote- durch C#-Tags ersetzt


Zuletzt bearbeitet von matze94 am Sa 20.03.10 14:06, insgesamt 1-mal bearbeitet
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Fr 19.03.10 20:42 
In der Tat: ziemlich wild. Als erstes solltest du den Code richtig markieren, nämlich wie von Christian in deinem ersten Beitrag korrigiert, unter "Bereiche" mit der Auswahl von C#. Wenn dann auch noch Einrückungen erkennbar sind, dann kann man anfangen nachzudenken.

Also bitte: geh mit dem Schere-Button auf deinen Beitrag, mache aus Zitat ein [ cs] (natürlich ohne Leerzeichen), dann absenden.

Jürgen
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 19.03.10 21:07 
user profile iconmatze94 hat folgendes geschrieben Zum zitierten Posting springen:
äh wo sol ich das ding hinpacken
Ich habe nichts davon geschrieben, dass du eine neue property oder so deklarieren musst. Die Angabe, die ich verlinkt habe, enthält einfach das Verzeichnis deiner Exe das kannst du direkt benutzen...
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 24.03.10 15:55 
wenn ich dich richtig verstanden habe dann so:

ausblenden 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:
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            System.Diagnostics.Process.Start("explorer"@"public static string StartupPath { get; }\DATA");
        }

        private void button2_Click(object sender, EventArgs e)
        {

            System.Diagnostics.Process.Start("explorer"@"public static string StartupPath { get; }"); 
        }

        private void button3_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("public static string StartupPath { get; }/PStart.exe""");
            
        }
    }
}


trotzdem funktioniert es nicht auch nicht button2 die anderen muss ich dann noch mit diesen Path.Combine zusammenfügen oder?
norman2306
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 222
Erhaltene Danke: 16

Win XP, Win 7 64-Bit
C# 4.0 (VS2010)
BeitragVerfasst: Mi 24.03.10 16:25 
Das kann auch nicht funktionieren...
Probiere es mal so:
ausblenden C#-Quelltext
1:
System.Diagnostics.Process.Start("PStart.exe", Application.StartupPath + @"\Data\");					

oder mit
ausblenden C#-Quelltext
1:
2:
string path = Path.Combine(Application.StartupPath, @"\Data\");
System.Diagnostics.Process.Start("PStart.exe",  path);

Theoretisch kannst du den Application.StartupPath sogar weglassen, weil C# standardmäßig bei einer relativen Pfadangabe vom aktuellen Pfad ausgeht... also:
ausblenden C#-Quelltext
1:
System.Diagnostics.Process.Start("PStart",  @"Data\");					
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 24.03.10 17:28 
jetzt funktionierts
außer button 3

ausblenden 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:
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string path = Path.Combine(Application.StartupPath, @"\Data\");
            System.Diagnostics.Process.Start("explorer",  path);
        }

        private void button2_Click(object sender, EventArgs e)
        {

            string path = Path.Combine(Application.StartupPath, @"\");
            System.Diagnostics.Process.Start("explorer", path);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string path = Application.StartupPath;
            System.Diagnostics.Process.Start("autorun", path);
            
        }
    }
}
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Mi 24.03.10 18:22 
"autorun" ist auch kein Programm, sondern ein Parameter oder (je nach Situation) eine Einstellung für die Registry. Jürgen
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 24.03.10 20:28 
user profile iconJüTho hat folgendes geschrieben Zum zitierten Posting springen:
"autorun" ist auch kein Programm, sondern ein Parameter oder (je nach Situation) eine Einstellung für die Registry. Jürgen


ne autorun ist eine .exe die im gleichen Verzeichnis liegt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 25.03.10 01:31 
Und was passiert? Welcher Fehler kommt? Denn wenn z.B. die Datei nicht gefunden wird, gibts auch eine entsprechende Exception.
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 25.03.10 06:29 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Und was passiert? Welcher Fehler kommt? Denn wenn z.B. die Datei nicht gefunden wird, gibts auch eine entsprechende Exception.


ja er findet die datei nicht obwohl sie im gleichen Verzeichnis liegt ich glaub der sucht die Datei in Windows und nicht im gleichen Verzeichnis
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Do 25.03.10 11:38 
Der sucht die Datei nirgends anders als in deinem Application.StartupPath. Wenn du dir die "Mühe" machst zu debuggen siehst du doch den Pfad. Den du dann mit deinem "gewünschten" Pfad vergleichen kannst. Ich weiß nicht wie man ein Thema so durcheinander bringen kann :/
norman2306
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 222
Erhaltene Danke: 16

Win XP, Win 7 64-Bit
C# 4.0 (VS2010)
BeitragVerfasst: Do 25.03.10 14:09 
schau doch einfach mal, was du bei button2 anders gemacht hast, dass es da funtioniert hat... dein "explorer" liegt ja anscheinend auch im StartupPath und den findet er.
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 25.03.10 18:32 
user profile iconnorman2306 hat folgendes geschrieben Zum zitierten Posting springen:
schau doch einfach mal, was du bei button2 anders gemacht hast, dass es da funtioniert hat... dein "explorer" liegt ja anscheinend auch im StartupPath und den findet er.


der explorer ist der windows explorer mit dem man ordner anzeigt also windows intern, pstart.exe o. autorun.exe sind in den ordner wo das proramm ausgeführt wird also windows extern macht das was? oder sucht der nicht den aktuellen ordner nach der datei ab?
matze94 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 25.03.10 21:03 
also jetzt funktionierts wenn ich die .exe und nicht die .application nehm, dann brauch ich auch nichts installieren