2
有誰知道爲什麼這個失敗運行。 我有這個代碼和一個名爲logo.png的文件在同一個目錄中。 然後我運行此代碼,它失敗了,說它無法找到該文件GTK#窗口圖標不起作用
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()'可以告訴你當前工作目錄在哪裏。 – 2013-05-10 04:02:46