import dotNet; dotNet.import("System.IO","mscorlib"); //扩展构造函数 System.IO.StreamReader[["ctor(...)"]] = function(netCtor,path,...){ //修改构造函数参数 if(type.isString(path)){ path = ..io.fullpath(path) } //调用真实的 .NET 构造函数 netCtor 创建并返回 .NET 对象 。 return netCtor(path,...); } //扩展构造函数 System.IO.StreamWriter[["ctor(...)"]] = function(netCtor,path,...){ //修改构造函数参数 if(type.isString(path)){ path = ..io.fullpath(path) } //调用真实的 .NET 构造函数 netCtor 创建并返回 .NET 对象 。 return netCtor(path,...); } //扩展构造函数 System.IO.FileStream[["ctor(...)"]] = function(netCtor,path,mode,...){ //修改构造函数参数 if(type.isString(path)){ path = ..io.fullpath(path) } //修改构造函数参数,调用真实的 .NET 构造函数 var obj,err; if(type.isString(mode)){ if(mode=="w+"){ obj,err = netCtor(path,2,3/*ReadWrite*/,...); } elseif(mode=="r+"){ obj,err = netCtor(path,3,3/*ReadWrite*/,...); } elseif(mode=="a+"){ obj,err = netCtor(path,4,3/*ReadWrite*/,...); if(obj){ obj.Seek(0,2/*SeekOrigin.End*/) } } elseif(mode=="r"){ obj,err = netCtor(path,3,1/*Read*/,...); } elseif(mode=="a"){ obj,err = netCtor(path,6,2,...); } elseif(mode=="w"){ obj,err = netCtor(path,2,2,...); } } else { obj,err = netCtor(path,mode,...); } //返回 .NET 对象 。 return obj,err; } var Create = System.IO.File.Create; System.IO.File.Create = function(path,...){ return Create(..io.fullpath(path),...); } var CreateText = System.IO.File.CreateText; System.IO.File.CreateText = function(path,...){ return CreateText(..io.fullpath(path),...); } var Open = System.IO.File.Open; System.IO.File.Open = function(path,...){ return Open(..io.fullpath(path),...); } var OpenRead = System.IO.File.OpenRead; System.IO.File.OpenRead = function(path,...){ return OpenRead(..io.fullpath(path),...); } var OpenText = System.IO.File.OpenText; System.IO.File.OpenText = function(path,...){ return OpenText(..io.fullpath(path),...); } var OpenWrite = System.IO.File.OpenWrite; System.IO.File.OpenWrite = function(path,...){ return OpenWrite(..io.fullpath(path),...); } var OpenWrite = System.IO.File.WriteAllBytes; System.IO.File.WriteAllBytes = function(path,...){ return OpenWrite(..io.fullpath(path),...); } System.IO.Ports = ..dotNet.import("System.IO.Ports","System"); /**intellisense() System.IO = .NET System.IO 命名空间 System.IO.? = .NET 命名空间、类、结构体的成员,\n可访问成员命名空间、类、枚举、静态属性或字段,\n导入的类可用于构造 .NET 对象,传回 .NET 则自动转为该类的 Type 对象\n!dotNetNameSpace. System.IO.__assembly__ = 导入此 .NET 命名空间的程序集对象。\n!dotNetCrlAssembly. System.IO.FileStream = 创建 .NET 文件流对象。\n如果参数 @1 为字符串,则自动调用 io.fullpath 转换为绝对路径。\n参数 @2 也可以用与 io.file 兼容的字符串参数指定读写模式:\n "r+","w+","a+","r","w","a"\n\n此对象调用 Write 函数写数据时应当传字节串( buffer 类型),\n可用 raw.buffer 创建 buffer (字节串)作为参数 System.IO.File = 文件操作 System.IO.File.Create(__) = 创建文件,返回 System.IO.FileStream 对象。\n参数 @1 已自动调用 io.fullpath 转换为完整路径 System.IO.File.CreateText(__) = 创建或打开 UTF-8 编码的文本文件。\n返回 System.IO.FileStream 对象。\n参数 @1 已自动调用 io.fullpath 转换为完整路径 System.IO.File.Open(__) = 打开文件,返回 System.IO.FileStream 对象。\n参数 @1 已自动调用 io.fullpath 转换为完整路径 System.IO.File.OpenRead(__) = 打开存在的文件用于读取内容。\n返回 System.IO.FileStream 对象。\n参数 @1 已自动调用 io.fullpath 转换为完整路径 System.IO.File.OpenText(__) = 开存在的文件用于读取 UTF-8 编码文本。\n返回 System.IO.FileStream 对象。\n参数 @1 已自动调用 io.fullpath 转换为完整路径 System.IO.File.OpenWrite(__) = 打开或创建文件用于写入。\n返回 System.IO.FileStream 对象。\n参数 @1 已自动调用 io.fullpath 转换为完整路径 System.IO.StreamWriter(__) = 返回 StreamWriter 实例,以特定编码写入文本。\n如果参数 @1 为字符串,则自动调用 io.fullpath 转换为绝对路径 System.IO.StreamReader(__) = 返回 StreamReader 实例,以特定编码读文本。\n如果参数 @1 为字符串,则自动调用 io.fullpath 转换为绝对路径 System.IO.FileMode.CreateNew = 值为 1 System.IO.FileMode.Create = 值为 2 System.IO.FileMode.Open = 值为 3 System.IO.FileMode.OpenOrCreate = 值为 4 System.IO.FileMode.Truncate = 值为 5 System.IO.FileMode.Append = 值为 6 System.IO.FileAccess.Read = 值为 1 System.IO.FileAccess.Write = 值为 2 System.IO.FileAccess.ReadWrite = 值为 3 System.IO.MemoryStream() = 创建 .NET 内存文件流,返回 System.IO.MemoryStream 对象。 end intellisense**/