zoukankan
html css js c++ java
文件创建及读取的方法
以前创建用
String filePath
=
HttpContext.Current.Server.MapPath(FileName);
if
(
!
System.IO.File.Exists(filePath))
//
创建文件
System.IO.File.Create(filePath);
System.IO.StreamWriter sw
=
new
System.IO.StreamWriter(filePath,
false
);
sw.WriteLine(html);
sw.Close();
读取用
if
(System.IO.File.Exists(filePath))
{
//
System.IO.FileStream fs = System.IO.File.OpenRead(filePath);
FileStream fs
=
new
FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sr
=
new
StreamReader(filePath, System.Text.Encoding.UTF8);
//
StreamReader sr = new StreamReader(filePath);
while
(sr.Peek()
>
-
1
)
//
StreamReader.Peek()返回下一个可用字符,但不使用它
{
Response.Write(sr.ReadLine());
}
sr.Close();
fs.Close();
}
如果文件不存在的话,就会有
文件“G:\wwwRoot\wufengBS\文件处理\code.xls”正由另一进程使用,因此该进程无法访问该文件。
的错误。
改用流创建即可:
if
(
!
System.IO.File.Exists(filePath))
//
创建文件
{
System.IO.FileStream fs
=
System.IO.File.Create(filePath);
fs.Close();
}
查看全文
相关阅读:
rails best particseceeeeeeeeeeee
clear out all firefox plugin
named scope on rail3
javascript保留两位小数
rails
CVSNT权限配置
rails session使用好文章
rails session security
javascript断点调试方法
rails3发邮件
原文地址:https://www.cnblogs.com/wf225/p/571768.html
最新文章
又是一个相当 带劲的招聘起事
ruby hash usage
一个分页效果ruby版可作为面试题吧
kindeditor的使用
spring.net 的话题
前两天我的电脑不能上网今天恢复了我确定是360和腾讯的缘故
rails current path
http://m.onkey.org/2010/1/22/activerecordqueryinterface
after sudo aptget update && upgrade issue for mysql
ruby python syntx compare
热门文章
when you update linux kernel you need recompile virtual kernel,otherwise it couldn't work
ruby hash turtorial
微博营销
rails decimal keep three position after point
买了几本复印的ruby书,有图有真像
good rails site
check radio button is checked use jquery
一则招聘有意思
javascript convert str to number
rails scope for rail3
Copyright © 2011-2022 走看看