说的详细一些哦
tempstring ="asdfdsfdsfds"
filename = "d:\zd222.htm"
Dim objwriter As New StreamWriter(filename, False)
'' objwriter.Encoding = System.Text.Encoding.UTF8
objwriter.Write(tempstring)
objwriter.Close()
5 个解决方案
#1
我这里也是这个德性,希望解决
#2
大概是
GetEncoder()
你自己找找
GetEncoder()
你自己找找
#3
public void CreateTextFile(string fileName, string textToAdd) {
string logFile = DateTime.Now.ToShortDateString()
.Replace(@"/",@"-").Replace(@"\",@"-") + ".log";
FileStream fs = new FileStream(fileName,
FileMode.CreateNew, FileAccess.Write, FileShare.None);
StreamWriter swFromFile = new StreamWriter(logFile);
swFromFile.Write(textToAdd);
swFromFile.Flush();
swFromFile.Close();
StreamWriter swFromFileStream = new StreamWriter(fs);
swFromFileStream.Write(textToAdd);
swFromFileStream.Flush();
swFromFileStream.Close();
StreamWriter swFromFileStreamDefaultEnc =
new System.IO.StreamWriter(fs,
System.Text.Encoding.Default);
swFromFileStreamDefaultEnc.Write(textToAdd);
swFromFileStreamDefaultEnc.Flush();
swFromFileStreamDefaultEnc.Close();
StreamWriter swFromFileTrue =
new StreamWriter(fileName,true);
swFromFileTrue.Write(textToAdd);
swFromFileTrue.Flush();
swFromFileTrue.Close();
StreamWriter swFromFileTrueUTF8Buffer =
new StreamWriter(fileName,
true, System.Text.Encoding.UTF8,512);
swFromFileTrueUTF8Buffer.Write(textToAdd);
swFromFileTrueUTF8Buffer.Flush();
swFromFileTrueUTF8Buffer.Close();
StreamWriter swFromFileTrueUTF8 =
new StreamWriter(fileName, true,
System.Text.Encoding.UTF8);
swFromFileTrueUTF8.Write(textToAdd);
swFromFileTrueUTF8.Flush();
swFromFileTrueUTF8.Close();
StreamWriter swFromFileStreamUTF8Buffer =
new StreamWriter(fs, System.Text.Encoding.UTF8, 512);
swFromFileStreamUTF8Buffer.Write(textToAdd);
swFromFileStreamUTF8Buffer.Flush();
swFromFileStreamUTF8Buffer.Close();
}
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的语言筛选器按钮 。
string logFile = DateTime.Now.ToShortDateString()
.Replace(@"/",@"-").Replace(@"\",@"-") + ".log";
FileStream fs = new FileStream(fileName,
FileMode.CreateNew, FileAccess.Write, FileShare.None);
StreamWriter swFromFile = new StreamWriter(logFile);
swFromFile.Write(textToAdd);
swFromFile.Flush();
swFromFile.Close();
StreamWriter swFromFileStream = new StreamWriter(fs);
swFromFileStream.Write(textToAdd);
swFromFileStream.Flush();
swFromFileStream.Close();
StreamWriter swFromFileStreamDefaultEnc =
new System.IO.StreamWriter(fs,
System.Text.Encoding.Default);
swFromFileStreamDefaultEnc.Write(textToAdd);
swFromFileStreamDefaultEnc.Flush();
swFromFileStreamDefaultEnc.Close();
StreamWriter swFromFileTrue =
new StreamWriter(fileName,true);
swFromFileTrue.Write(textToAdd);
swFromFileTrue.Flush();
swFromFileTrue.Close();
StreamWriter swFromFileTrueUTF8Buffer =
new StreamWriter(fileName,
true, System.Text.Encoding.UTF8,512);
swFromFileTrueUTF8Buffer.Write(textToAdd);
swFromFileTrueUTF8Buffer.Flush();
swFromFileTrueUTF8Buffer.Close();
StreamWriter swFromFileTrueUTF8 =
new StreamWriter(fileName, true,
System.Text.Encoding.UTF8);
swFromFileTrueUTF8.Write(textToAdd);
swFromFileTrueUTF8.Flush();
swFromFileTrueUTF8.Close();
StreamWriter swFromFileStreamUTF8Buffer =
new StreamWriter(fs, System.Text.Encoding.UTF8, 512);
swFromFileStreamUTF8Buffer.Write(textToAdd);
swFromFileStreamUTF8Buffer.Flush();
swFromFileStreamUTF8Buffer.Close();
}
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的语言筛选器按钮 。
#4
Dim objwriter As New StreamWriter(filename, False)
==>
Dim objwriter As New StreamWriter(filename, False,System.Text.ASCIIEncoding)
==>
Dim objwriter As New StreamWriter(filename, False,System.Text.ASCIIEncoding)
#5
谢谢各位大哥
#1
我这里也是这个德性,希望解决
#2
大概是
GetEncoder()
你自己找找
GetEncoder()
你自己找找
#3
public void CreateTextFile(string fileName, string textToAdd) {
string logFile = DateTime.Now.ToShortDateString()
.Replace(@"/",@"-").Replace(@"\",@"-") + ".log";
FileStream fs = new FileStream(fileName,
FileMode.CreateNew, FileAccess.Write, FileShare.None);
StreamWriter swFromFile = new StreamWriter(logFile);
swFromFile.Write(textToAdd);
swFromFile.Flush();
swFromFile.Close();
StreamWriter swFromFileStream = new StreamWriter(fs);
swFromFileStream.Write(textToAdd);
swFromFileStream.Flush();
swFromFileStream.Close();
StreamWriter swFromFileStreamDefaultEnc =
new System.IO.StreamWriter(fs,
System.Text.Encoding.Default);
swFromFileStreamDefaultEnc.Write(textToAdd);
swFromFileStreamDefaultEnc.Flush();
swFromFileStreamDefaultEnc.Close();
StreamWriter swFromFileTrue =
new StreamWriter(fileName,true);
swFromFileTrue.Write(textToAdd);
swFromFileTrue.Flush();
swFromFileTrue.Close();
StreamWriter swFromFileTrueUTF8Buffer =
new StreamWriter(fileName,
true, System.Text.Encoding.UTF8,512);
swFromFileTrueUTF8Buffer.Write(textToAdd);
swFromFileTrueUTF8Buffer.Flush();
swFromFileTrueUTF8Buffer.Close();
StreamWriter swFromFileTrueUTF8 =
new StreamWriter(fileName, true,
System.Text.Encoding.UTF8);
swFromFileTrueUTF8.Write(textToAdd);
swFromFileTrueUTF8.Flush();
swFromFileTrueUTF8.Close();
StreamWriter swFromFileStreamUTF8Buffer =
new StreamWriter(fs, System.Text.Encoding.UTF8, 512);
swFromFileStreamUTF8Buffer.Write(textToAdd);
swFromFileStreamUTF8Buffer.Flush();
swFromFileStreamUTF8Buffer.Close();
}
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的语言筛选器按钮 。
string logFile = DateTime.Now.ToShortDateString()
.Replace(@"/",@"-").Replace(@"\",@"-") + ".log";
FileStream fs = new FileStream(fileName,
FileMode.CreateNew, FileAccess.Write, FileShare.None);
StreamWriter swFromFile = new StreamWriter(logFile);
swFromFile.Write(textToAdd);
swFromFile.Flush();
swFromFile.Close();
StreamWriter swFromFileStream = new StreamWriter(fs);
swFromFileStream.Write(textToAdd);
swFromFileStream.Flush();
swFromFileStream.Close();
StreamWriter swFromFileStreamDefaultEnc =
new System.IO.StreamWriter(fs,
System.Text.Encoding.Default);
swFromFileStreamDefaultEnc.Write(textToAdd);
swFromFileStreamDefaultEnc.Flush();
swFromFileStreamDefaultEnc.Close();
StreamWriter swFromFileTrue =
new StreamWriter(fileName,true);
swFromFileTrue.Write(textToAdd);
swFromFileTrue.Flush();
swFromFileTrue.Close();
StreamWriter swFromFileTrueUTF8Buffer =
new StreamWriter(fileName,
true, System.Text.Encoding.UTF8,512);
swFromFileTrueUTF8Buffer.Write(textToAdd);
swFromFileTrueUTF8Buffer.Flush();
swFromFileTrueUTF8Buffer.Close();
StreamWriter swFromFileTrueUTF8 =
new StreamWriter(fileName, true,
System.Text.Encoding.UTF8);
swFromFileTrueUTF8.Write(textToAdd);
swFromFileTrueUTF8.Flush();
swFromFileTrueUTF8.Close();
StreamWriter swFromFileStreamUTF8Buffer =
new StreamWriter(fs, System.Text.Encoding.UTF8, 512);
swFromFileStreamUTF8Buffer.Write(textToAdd);
swFromFileStreamUTF8Buffer.Flush();
swFromFileStreamUTF8Buffer.Close();
}
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的语言筛选器按钮 。
#4
Dim objwriter As New StreamWriter(filename, False)
==>
Dim objwriter As New StreamWriter(filename, False,System.Text.ASCIIEncoding)
==>
Dim objwriter As New StreamWriter(filename, False,System.Text.ASCIIEncoding)
#5
谢谢各位大哥