最佳解答者
Problem on writing a chinese character by ASP.Net

問題
-
Hi all,
I am having a problem on writing a chinese character to a text file by asp.net. It works fine on writing non-chinese character. Could you give me some suggestions whether I need to change some of my code or server's settings to get it work?
Sample code:
Dim objFSO = CreateObject("scripting.filesystemobject")
Dim objOutput = objFSO.CreateTextFile("FIlename", True)
objOutput.WriteLine("中文") <- it fails with following error:Server Error in '/' Application.
Exception from HRESULT: 0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL)2008年4月11日 上午 07:12
解答
-
Hi chiuching,
If you're using ASP.NET, you are recommended to use System.IO namespace for text file reading/writing.
For example,
Code SnippetSystem.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter("Sample1.txt");
StreamWriter1.WriteLine("PutYourContentHere");
StreamWriter1.Close();Regards,
Colt
2008年4月21日 上午 02:24
所有回覆
-
Hi chiuching,
If you're using ASP.NET, you are recommended to use System.IO namespace for text file reading/writing.
For example,
Code SnippetSystem.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter("Sample1.txt");
StreamWriter1.WriteLine("PutYourContentHere");
StreamWriter1.Close();Regards,
Colt
2008年4月21日 上午 02:24 -
ColtK 寫信: Hi chiuching,
If you're using ASP.NET, you are recommended to use System.IO namespace for text file reading/writing.
For example,
Code SnippetSystem.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter("Sample1.txt");
StreamWriter1.WriteLine("PutYourContentHere");
StreamWriter1.Close();Regards,
Colt
That's the exactly solution I have found.
Thx anyway.
Regards.
2008年4月21日 上午 03:02