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

推荐订阅源

The Register - Security
The Register - Security
GbyAI
GbyAI
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
罗磊的独立博客
P
Proofpoint News Feed
A
About on SuperTechFans
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
D
DataBreaches.Net
V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
V
V2EX
博客园_首页
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
人人都是产品经理
人人都是产品经理
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
L
LangChain Blog
博客园 - 三生石上(FineUI控件)
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cloudbric
Cloudbric
L
LINUX DO - 最新话题
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
Engineering at Meta
Engineering at Meta
The Hacker News
The Hacker News
Hacker News: Ask HN
Hacker News: Ask HN
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
PCI Perspectives
PCI Perspectives
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
The Cloudflare Blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - Juniy

DedeCms 模板学习1 DIV盒子的CSS平面图 在asp.net页面中传递中文参数 - Juniy - 博客园 sqldatasource连接excel 2003 - Juniy - 博客园 SSI与SHTML学习 AjaxPro(ajax架构)在ASP.NET中的使用 常用命令备忘 .NET 实现ISAPI过滤器,指定类型文件防下载 ASP.NET"正在中止线程"错误原因 将用户重定向到另一页的几种方法 贝塞尔样条 PetShop4 下载地址 ASCII 非打印控制字符表 (摘抄)什么是反射机制 (摘抄)禁止搜索引擎收录的方法(robots.txt文件的使用) (摘抄)DIV布局和网页设计 C#中using的使用 修改url前图标(网上查到) JavaScript小技巧一
ASP.NET(C#)文件读写函数
Juniy · 2006-10-23 · via 博客园 - Juniy

using System;
using System.Data;
using System.IO;
using System.Text;

public void WriteFile(string content, string fileSavePath)
{
           
if (System.IO.File.Exists(fileSavePath))
        
{
            System.IO.File.Delete(fileSavePath);
        }

        
using (System.IO.FileStream fs = System.IO.File.Create(fileSavePath)) 
        
{
            
byte[] info = new System.Text.Encoding.GetEncoding("gb2312").GetBytes(content);   //防止乱码
            fs.Write(info, 0, info.Length);
        }

}

public string ReadFile(string fileOpenPath)
{
           
if (!System.IO.File.Exists(fileOpenPath))
        
{
            
return null;
        }

        
using (System.IO.StreamReader sr = System.IO.File.OpenText(fileOpenPath)) 
        
{
            
return  sr.ReadToEnd().ToString();
        }

}

posted @ 2006-10-23 16:19  Juniy  阅读(827)  评论(2)    收藏  举报

刷新页面返回顶部