OpenFileDialog
打开一个文件
|
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
label1.Text = openFileDialog1.FileName;
System.IO.StreamReader str = new System.IO.StreamReader(openFileDialog1.FileName);
textBox1.Text = str.ReadToEnd();
str.Close();
}
} |
打开多个文件
|
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
foreach (var FileName in openFileDialog1.FileNames)
{
listView1.Items.Add(FileName);
}
}
} |
OpenFileDialog的更多相关文章
- 1、怎样设置C#OpenFileDialog(文件选择窗体)的指定路径、文件格式等属性(设置打开默认路径、文件格式、窗体显示文本)
C#的OpenFileDialog的常用属性设置 1.设置属性 1)设置弹出的指定路径(绝对路径.相等路径) 2)设置标题 3)设置文本格式 2.打开方式1(绝对路径) 2.1) 打开的路径
- Dev 关于用openFileDialog控件上传图片的问题
1. OpenFileDialog控件有以下基本属性 InitialDirectory 对话框的初始目录 Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.tx ...
- C# winform OpenFileDialog MessageBox
1.弹出窗体选择本地文件-OpenFileDialog OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Tit ...
- OpenFileDialog获取文件名和文件路径问题
OpenFileDialog获取文件名和文件路径问题(转) 转自:http://blog.sina.com.cn/s/blog_7511914e0101cbjn.html System.IO.Path ...
- 使用OpenFileDialog会更改默认程序目录
这个问题可能只有在特定的程序中会发现:当我们在程序中使用相对路径时是依赖于当前目录的.所以在使用类似代码: XElement rootNode = XElement.Load(@"zips/ ...
- OpenFileDialog - 设置 - Filter 笔记
using (OpenFileDialog fileSelectDialog = new OpenFileDialog()) { fileSelectDialog.Multiselect = fals ...
- C#的OpenFileDialog和SaveFileDialog的常见用法(转)
OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = ...
- C# OpenFileDialog
OpenFileDialog 用于浏览并打开文件,在Windows Forms中使用,表现为标准的Windows对话框. 实例: 1.新建Windows Form Application 2.添加Op ...
- OpenFileDialog使用方法
OpenFileDialog基本属性 AddExtension 控制是否将扩展名自动添加到文件名上 CheckFileExists 指示用户指定不存在的文件时是否显示警告 CheckPathExist ...
- C# OpenFileDialog和PictrueBox
string resultFile = ""; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFile ...
随机推荐
- Prism vs MvvmCross
Prism vs MvvmCross 在上一篇Xamarin开发环境及开发框架初探中,曾简单提到MvvmCross这个Xamarin下的开发框架.最近又评估了一些别的,发现老牌Mvvm框架Prism现 ...
- OC中格式化输出符号
定义 说明 %@ Objective-C object, printed as the string returned by descriptionWithLocale: if available, ...
- skiplist 跳表(2)-----细心学习
快速了解skiplist请看:skiplist 跳表(1) http://blog.sina.com.cn/s/blog_693f08470101n2lv.html 本周我要介绍的数据结构,是我非常非 ...
- ECMall系统请求跳转分析
ecmall是一个基于mvc模式框架系统,跟thinkphp有点像.先从ecmall的入口开始,ecmall入口文件upload/index.php.admin.php: index.php启动ecm ...
- SET NOCOUNT用法
当 SET NOCOUNT 为 ON 时,不返回计数(表示受 Transact-SQL 语句影响的行数). 当 SET NOCOUNT 为 OFF 时,返回计数. 如果存储过程中包含的一些语句并不返回 ...
- UVA 1513 Movie collection
#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 200010 #define l ...
- OA学习笔记-001-项目介绍
基本知识 框架工具 解决方案(经典应用) 项目 12天 ========================================== OA项目, 12天 BBS 一.什么是OA? 辅助管理.提 ...
- Android 自定义组件随着手指自动画圆
首先自定义一个View子类: package com.example.androidtest0.myView; import android.content.Context; import andro ...
- Python Monkey patch猴子补丁
monkey patch (猴子补丁) 用来在运行时动态修改已有的代码,而不需要修改原始代码. 简单的monkey patch 实现:[python] #coding=utf-8 def orig ...
- bzoj1758
好题显然是分数规划,二分答案之后我们要找是否存在一条边数在[l,u]长度和为正的路径可以用树的分治来解决这个问题我们假设当前处理的是过点root的路径显然我们不好像之前男人八题里先算出所有答案,然后再 ...