[介绍]
GoDaddy美国主机支持FSO生成页面
|
|
如题, GoDaddy Windows主机是支持FSO生成页面, FSO组件全称为:FileSystemObject
GoDaddy支持的组件一览表地址:http://help.godaddy.com/article/1584
有朋友FSO的时候出现错误,一般由如下原因造成:
设置读写权限参考:GoDaddy主机设置读写权限教程
路径问题,可能需要简单修改一下代码
比如关于新云cms的:GoDaddy主机新云cms生成html静态页面为0的解决方法
比如下面这个实例代码是错误的:- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.IO;
- using System.Text;
- using System.Security.Permissions;
- public partial class cvInserting : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
-
- public class test
- {
- public static void Main()
- {
- string path = @"C:\TestFile.Txt";
- try
- {
- using (FileStream fs = File.Create(path))
- {
- byte[] info = new UTF8Encoding(true).GetBytes("this is a test.");
- fs.Write(info, 0, info.Length);
- }
- using (StreamReader sr = File.OpenText(path))
- {
- string s = "this is a test";
- while ((s = sr.ReadLine()) != null)
- {
- Console.WriteLine(s);
- }
- }
- }
- catch (Exception Ex)
- {
- Console.WriteLine(Ex.ToString());
- }
- }
-
- }
- }
复制代码 改为如下代码则运行的非常好:- using System;
- using System.IO;
- using System.Text;
- public partial class cvInserting : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- // The path to file in the data directory.
- // Data directory must have a write access enabled
- string path = Server.MapPath("/TestFile.Txt");
- using (FileStream fs = File.Create(path))
- {
- byte[] info = new UTF8Encoding(true).GetBytes("this is a test.");
- fs.Write(info, 0, info.Length);
- }
- using (StreamReader sr = File.OpenText(path))
- {
- string s;
- while ((s = sr.ReadLine()) != null)
- {
- Response.Write(s);
- }
- }
- }
- }
复制代码 |
|
|
|
|
|
|
|
|