using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SaveFileDialogDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 保存文件按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_SaveFile_Click(object sender, EventArgs e)
{
//
SaveFileDialog sfd = new SaveFileDialog();
//设置保存文件对话框的标题
sfd.Title = "请选择要保存的文件路径";
//初始化保存目录,默认exe文件目录
sfd.InitialDirectory = Application.StartupPath;
//设置保存文件的类型
sfd.Filter = "文本文件|*.txt|音频文件|*.wav|图片文件|*.jpg|所有文件|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
//获得保存文件的路径
string filePath = sfd.FileName;
//保存
using (FileStream fsWrite = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write))
{
byte[] buffer = Encoding.Default.GetBytes(txt_FileInfo.Text.ToString().Trim());
fsWrite.Write(buffer, 0, buffer.Length);
}
}
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有