Seiten

Donnerstag, 29. Oktober 2009

.NET: URI-Formate werden nicht unterstützt

Ich bekomme diese Fehlermeldung wenn ich eine Pfadangabe erzeugt z.B. durch...
this.appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

... wie hier direkt verwende.
backShot.Save(this.appPath + @"\_backshot.bmp", ImageFormat.Bmp);
Ausgabe: "file:\C:\Users\dutzend..."

Die Meldung wird also durch das Protokoll-Prefix ausgelöst.

Workaround:
this.appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

if(this.appPath.Contains(@"file:\"))
  this.appPath = this.appPath.Substring(6);

Keine Kommentare:

Kommentar veröffentlichen