会员
周边
众包
新闻
博问
闪存
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
专注于.Net开发
博客园
园子
首页
新随笔
联系
管理
订阅
ASP.net 写文件的函数(内容,路径,文件名) pcsky(原作)
'
写文件的函数(内容,路径,文件名)
Public
Sub FileWrite()
Sub
FileWrite(
ByVal
Str
As
String
,
ByVal
myPath
As
String
,
ByVal
myFileName
As
String
)
Dim
path
As
String
=
HttpContext.Current.Server.MapPath(myPath)
'
路径
Dim
temp
As
String
=
path
&
"
"
&
myFileName
'
路径+文件名
'
删除原文件,如果存在
If
File.Exists(temp)
Then
File.Delete(temp)
End
If
'
建立新文件
Dim
fs
As
FileStream
=
File.Create(temp)
Dim
info
As
Byte
()
=
Encoding.GetEncoding(
"
gb2312
"
).GetBytes(
Str
)
'
把内容添加到文件中
fs.
Write
(info,
0
, info.Length)
fs.Close()
'
Response.Write("<br>文件成功写入!")
End Sub
posted @
2004-08-16 17:46
pcsky(进哥)
阅读(
3071
) 评论(
5
)
收藏
举报
刷新页面
返回顶部
公告