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

推荐订阅源

GbyAI
GbyAI
Simon Willison's Weblog
Simon Willison's Weblog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
Last Week in AI
Last Week in AI
月光博客
月光博客
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
U
Unit 42
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
H
Hacker News: Front Page
Recent Announcements
Recent Announcements
C
CXSECURITY Database RSS Feed - CXSecurity.com
Latest news
Latest news
小众软件
小众软件
P
Palo Alto Networks Blog
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
S
Secure Thoughts
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
O
OpenAI News
S
Securelist
云风的 BLOG
云风的 BLOG
H
Help Net Security
T
Troy Hunt's Blog

博客园 - 嚣张的沉默

限制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());
        }