9 个解决方案
#1
关闭stream,然后删除文件,重新创建文件。
#2
StreamWriter sw = new StreamWriter(path,false);
以重写方式打开写入即可
以重写方式打开写入即可
#3
Dim sw As StreamWriter = New StreamWriter(path,false)
#4
dim fi as new FileInfo(path)
if fi.Length>指定大小 then
if fi.Length>指定大小 then
#5
to:viena(维也纳nn)
还能具体一下吗?
怎么才是以重写方式打开阿?
还能具体一下吗?
怎么才是以重写方式打开阿?
#6
Dim sw as New StreamWriter(path,false);
就是以重写方式打开写入。path变量为文件的路径和文件名,false为append的值,当要追加文件时该值选true,选择false即为改写文件。
就是以重写方式打开写入。path变量为文件的路径和文件名,false为append的值,当要追加文件时该值选true,选择false即为改写文件。
#7
获取文件名->删除->创建同名文件
#8
是的,fice_chen(火冰)解释得不错
其实我已经给出代码了
其实我已经给出代码了
#9
If File.Exists(Application.StartupPath & "\b.txt") Then
Dim fi As New FileInfo(Application.StartupPath & "\b.txt")
MessageBox.Show(fi.Length)
If fi.Length > 100 Then
fi.Delete()
Dim sw As StreamWriter = New StreamWriter(Application.StartupPath & "\b.txt", True)
sw.Close()
End If
End If
Dim fi As New FileInfo(Application.StartupPath & "\b.txt")
MessageBox.Show(fi.Length)
If fi.Length > 100 Then
fi.Delete()
Dim sw As StreamWriter = New StreamWriter(Application.StartupPath & "\b.txt", True)
sw.Close()
End If
End If
#1
关闭stream,然后删除文件,重新创建文件。
#2
StreamWriter sw = new StreamWriter(path,false);
以重写方式打开写入即可
以重写方式打开写入即可
#3
Dim sw As StreamWriter = New StreamWriter(path,false)
#4
dim fi as new FileInfo(path)
if fi.Length>指定大小 then
if fi.Length>指定大小 then
#5
to:viena(维也纳nn)
还能具体一下吗?
怎么才是以重写方式打开阿?
还能具体一下吗?
怎么才是以重写方式打开阿?
#6
Dim sw as New StreamWriter(path,false);
就是以重写方式打开写入。path变量为文件的路径和文件名,false为append的值,当要追加文件时该值选true,选择false即为改写文件。
就是以重写方式打开写入。path变量为文件的路径和文件名,false为append的值,当要追加文件时该值选true,选择false即为改写文件。
#7
获取文件名->删除->创建同名文件
#8
是的,fice_chen(火冰)解释得不错
其实我已经给出代码了
其实我已经给出代码了
#9
If File.Exists(Application.StartupPath & "\b.txt") Then
Dim fi As New FileInfo(Application.StartupPath & "\b.txt")
MessageBox.Show(fi.Length)
If fi.Length > 100 Then
fi.Delete()
Dim sw As StreamWriter = New StreamWriter(Application.StartupPath & "\b.txt", True)
sw.Close()
End If
End If
Dim fi As New FileInfo(Application.StartupPath & "\b.txt")
MessageBox.Show(fi.Length)
If fi.Length > 100 Then
fi.Delete()
Dim sw As StreamWriter = New StreamWriter(Application.StartupPath & "\b.txt", True)
sw.Close()
End If
End If