【发布时间】:2013-12-04 13:59:17
【问题描述】:
有谁知道为什么这无法运行。 我在同一个目录中有这个代码和一个名为 logo.png 的文件。 然后我运行这段代码,它失败了,说它找不到文件
using System;
using Gtk;
public class Trackbox {
static int Main() {
Application.Init();
//Create the Window
Window myWin = new Window("TrackBox");
myWin.SetIconFromFile("logo.png");
myWin.Resize(200, 100);
//Create a label and put some text in it.
Label myLabel = new Label();
myLabel.Text = "Welcome to TrackBox";
//Add the label to the form
myWin.Add(myLabel);
//Show Everything
myWin.ShowAll();
Application.Run();
return 0;
}
}
它返回一个错误说它找不到logo.png...这是为什么?感谢您的帮助。
【问题讨论】:
-
.. 因为它不是你想的那样。关于当前工作目录,
logo.png在哪里?System.IO.Directory.GetCurrentDirectory()可以告诉你当前工作目录在哪里。