Directory.GetFiles()を使用して作成した画像の文字列配列から画像をpictureBoxにロードしようとしています。私はpicFileを正しく設定することを正しく設定していないと思います。画像の配列から画像をロードしようとしています
以降の画像をロードするためにpictureBox_Clickイベントを作成したよりも、私はしましたが、私はコンソールに文字列配列をリダイレクトする場合は、そのイベントハンドラ
string fileEntries = "";
private void showButton_Click(object sender, EventArgs e)
{
// First I want the user to be able to browse to and select a
// folder that the user wants to view pictures in
string folderPath = "";
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
folderPath = folderBrowserDialog1.SelectedPath;
}
// Now I want to read all of the files of a given type into a
// array that from the path provided above
ProcessDirectory(folderPath);
// after getting the list of path//filenames I want to load the first image here
string picFile = fileEntries;
pictureBox1.Load(picFile);
}
public static void ProcessDirectory(string targetDirectoy)
{
// Process the list of files found in the directory.
string[] fileEntries = Directory.GetFiles(targetDirectoy);
}
// event handler here that advances to the next picture in the list
// upon clicking
}
を書いていない私は、そのディレクトリ内のファイルのリストを参照してください、それまた、文字列の一部として完全なパスを持っています - それが問題かどうかはわかりません。
pictureBox1.Image = Image.FromFile(picFile)を試してみてください。 –