zoukankan
html css js c++ java
IO流读取与写入文件+SQL替换更新字段脚本
//流读取写入文件
读取文件
//
读文件操作
string
strFileContent
=
""
;
//
模版文件的全文内容
try
{
string
strLine
=
""
;
//
每行的内容
//
使用垃圾回收对该资源进行自动处置using就不用关闭对象,否则必须关闭strFileFullName文件路径。
using
(StreamReader fileRead
=
new
StreamReader(strFileFullName,Encoding.Default))
{
while
(fileRead.Peek()
>=
0
)
{
strLine
=
fileRead.ReadLine();
strFileContent
+=
strLine;
}
}
}
写入文件
//
写文件操作
//
为了保证文件的格式,替换部分字符串
strFileContent
=
strFileContent.Replace(
"
\t
"
,
"
\r\n\t
"
);
string
strErrmsg;
string
path;
if
(
!
File.Exists(strFileFullName))
{
//
strFileFullName文件物理路径
path
=
strFileFullName.Replace(
"
\\demo.txt
"
,
""
);
//
DirectoryInfo公用创建、移动、和枚举的实例方法
DirectoryInfo di
=
Directory.CreateDirectory(path);
//
创建文件以UTF-8的编码形式
StreamWriter sr
=
File.CreateText(strFileFullName);
sr.Close();
}
try
{
System.IO.StreamWriter fileWrite
=
new
StreamWriter(strFileFullName,
false
,Encoding.Default);
//
strFileContent 文件内容
fileWrite.Write(strFileContent);
fileWrite.Close();
}
//更新替换字段
update
UserInfo
set
URL_Name
=
(
select
replace
(URL_Name,
substring
(URL_Name,
0
,
17
),
'
http://hanguoji
'
))
where
substring
(URL_Name,
0
,
17
)
=
'
http://localhost
'
查看全文
相关阅读:
iOS之项目常见文件、UIApplication详解及UIApplicationDelegate的代理方法
ios关于uibutton内部结构
ios关于图片拉伸的版本间的几种方法
uitalbview加载xib详解
xcode4.2工程Created by名字的修改问题
工作中常用到的测试分享工具
IOS 分享 牛人 Demo
ios输入内容正则表达式的应用
ios-学习篇-归档
IOS-网络(GCD)
原文地址:https://www.cnblogs.com/hanguoji/p/439908.html
最新文章
Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它) 分类: Android 2014-05-26 21:42 1028人阅读 评论(1) 收藏
J2EE学习篇之--Struts2技术详解 分类: JavaWeb 2014-05-26 21:21 1640人阅读 评论(0) 收藏
J2EE学习篇之--Struts1详解 分类: JavaWeb 2014-05-23 09:15 997人阅读 评论(1) 收藏
解决SQLite中的 database is locked 分类: Android 2014-05-20 18:13 2389人阅读 评论(3) 收藏
J2EE学习篇之--JDBC详解 分类: JavaWeb 2014-05-18 20:05 2761人阅读 评论(1) 收藏
ios 字符串MD5加密,返回加密后的字符串
控制器的创建方式 -- 及其导航控制器的管理
UIView小总结
UIPickerView常用属性 -- 小总结
自定义Cell的步骤(封装思想)
热门文章
工作中的简单总结
工作中常用到的一些方法集合
常见错误收集
单例头文件
ios 开发中常用的宏
iOS之用uilabel弹出消息提示框
iOS之UIApplication详解(2)
IOS之UITableView详解(2)
ios之事件的传递过程总结
iOS之UIDynamic UI动力学使用步骤
Copyright © 2011-2022 走看看