惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
H
Help Net Security
Last Week in AI
Last Week in AI
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
B
Blog
C
Check Point Blog
T
Tailwind CSS Blog
云风的 BLOG
云风的 BLOG
D
Docker
Recent Announcements
Recent Announcements
Vercel News
Vercel News
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
月光博客
月光博客
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
The Register - Security
The Register - Security
V
Visual Studio Blog
F
Full Disclosure
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
PCI Perspectives
PCI Perspectives
Cisco Talos Blog
Cisco Talos Blog
博客园 - Franky
D
DataBreaches.Net
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
P
Palo Alto Networks Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
T
Tenable Blog
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy

博客园 - 嚣张的沉默

限制TextBox输入字数 计算TextBox输入的字数 我常用的正则与SQL语句 DataSet导入到Excel 年月日联动的JS代码 用户控件的传值方法 Repeater模板列 asp.net的几个小技巧 百叶窗效果 建站安全 倒计时代码 解决SQL2000安装服务器挂起 删除.NET的最近项目 屏幕右下角弹出广告 DataSet写入、导出XML 上传图片重命名并创建文件夹 自动跳转页面带参数 微软出的AJAX控件的安装(转载) 第一次开博
读写txt文档
嚣张的沉默 · 2008-04-09 · via 博客园 - 嚣张的沉默

写:

StreamWriter sw ;
sw 
= File.CreateText(@"e:\aa.txt");
sw.WriteLine(TextBox2.Text);
sw.Close();

读:

if (FileUpload1.PostedFile.FileName != "")
        
{
            FilePath 
= FileUpload1.PostedFile.FileName;
            fileExtName 
= FilePath.Substring(FilePath.LastIndexOf("."+ 13);
            
if (fileExtName.Equals("txt"))
            
{
                StreamReader fileStream 
= new StreamReader(this.FileUpload1.PostedFile.InputStream, Encoding.Default);

                
string filestr = fileStream.ReadToEnd();
                fileStream.Close();
                TextBox2.Text 
= filestr;
            }

            
else
            
{
                Response.Write(
"错了");
            }

        }

读Execl

string strFileName = FileUpload1.FileName;
        
string imgpath = Server.MapPath("~/inputFile/");
        FileUpload1.SaveAs(imgpath 
+ strFileName);
        
try
        
{
            
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + imgpath + "\\" + strFileName + ";" + "Extended Properties=Excel 8.0;";
            OleDbConnection conn 
= new OleDbConnection(strConn);
            OleDbDataAdapter oda 
= new OleDbDataAdapter("select * from [Sheet1$]", strConn); //oda.Fill(ds);
            oda.Fill(ds,"aa");
            GridView1.DataSource 
= ds.Tables["aa"];
            GridView1.DataBind();

        }

        
catch (Exception ex)
        
{
            Response.Write(ex.ToString());
        }