Form1.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//添加命名空间
using System.IO; //Directory目录
using System.Diagnostics; //Stopwatch显示时间
namespace GetPictureList
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// 下载于www.51aspx.com
//打开图片
private void button1_Click(object sender, EventArgs e)
{
//设置打开文件控件
OpenFileDialog openfile = new OpenFileDialog();
openfile.Filter = "JPG(*.JPG;*.JPEG);gif文件(*.GIF);BMP文件(*.BMP);PNG文件(*.PNG)|*.jpg;*.jpeg;*.gif;*.bmp;*.png";
openfile.FilterIndex = 1; //当前选定索引
openfile.RestoreDirectory = true;
openfile.FileName = "";
//对话框选择确定按钮
if (openfile.ShowDialog() == DialogResult.OK)
{
//FromFile从指定的文件创建Image
pictureBox1.Image = Image.FromFile(openfile.FileName);
//图片被拉伸或收缩适合pictureBox大小
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
}
}
//定义变量
private string folderDirPath; //图片文件夹地址
private string picDirPath = null; //图片路径
private List<string> imagePathList = new List<string>(); //获取列表图片路径
private int index; //获取选中列表图片序号
//ListView和imageList显示图片列表
private void button2_Click(object sender, EventArgs e)
{
try
{
//打开选择文件夹对话框
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
DialogResult result = folderBrowserDialog.ShowDialog();
if (result == DialogResult.OK)
{
//获取用户选择的文件夹路径
this.folderDirPath = folderBrowserDialog.SelectedPath;
后面还有 124 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。