仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 776|回复: 8
打印 上一主题 下一主题

[学习教程] ASP.NET编程:Reading/Writing text files using C#(...

[复制链接]
再见西城 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:50:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
数据挖掘有点高深的,主要估计就是使用一些算法提取一些实用的数据。学好数据挖掘的话可以应聘baidu或者google,但是一般人家对算法的要求听高的。你最好还是学点应用型的吧。这种主要是研究型的。Introduction
Readingandwritingtextfilesmaysometimesbequitehandyinprogramming.Youmightwanttomaintainyourowntext-styleconfigurationfiles.Oreditautoexec.batfromyourprogram.In.NetwehaveanabstractclasscalledaStreamclasswhichprovidesmethodstoreadandwritefromastore.TheFileStreamclassisaStreamclassderivedclasswhichwrapsthestreamingfunctionalityaroundafile.InthisarticleIlldemonstratehowyoucanusethisclassalongwithseveralreaderandwriterclassestoreadfromafile,writetoafile,createafileandevenretrieveinformationaboutafile.Ihaveprovidedacommentedprogrambelow.

TheProgram
usingSystem;
usingSystem.IO;
publicclassnishfiles
{
publicstaticvoidMain(String[]args)
{
//Createafilenish.txtinthecurrentdirectory
FileStreamfs=newFileStream("nish.txt",FileMode.Create,FileAccess.ReadWrite);

//NowletsputsometextintothefileusingtheStreamWriter
StreamWritersw=newStreamWriter(fs);
sw.WriteLine("Heynow!Heynow!
Iko,Iko,unday");
sw.WriteLine("Jockamofeenoainanay?
Jockamofeenanay?");
sw.Flush();

//WecanreadthefilenowusingStreamReader
StreamReadersr=newStreamReader(fs);
sr.BaseStream.Seek(0,SeekOrigin.Begin);
strings1;
Console.WriteLine("abouttoreadfileusingStreamReader.ReadLine()");
Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
while((s1=sr.ReadLine())!=null)
Console.WriteLine(s1);
Console.WriteLine();

//WecanreadthefilenowusingBinaryReader
BinaryReaderbr=newBinaryReader(fs);
br.BaseStream.Seek(0,SeekOrigin.Begin);
Byteb1;
Console.WriteLine("abouttoreadfileusingBinaryReader.ReadByte()");
Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
while(br.PeekChar()>-1)
{
b1=br.ReadByte();
Console.Write("{0}",b1.ToChar());
if(b1!=13&&b1!=10)
Console.Write(".");
}
br.Close();
Console.WriteLine();

sw.Close();
sr.Close();
fs.Close();

//UsetheFileclasstogetsomeinfoonourfile
Console.WriteLine("PrintsomeinfoonourfileusingtheFileclass");
Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
Filef=newFile("nish.txt");
Console.WriteLine("Filename:{0}",f.Name);
Console.WriteLine("Filenameinfull:{0}",f.FullName);
Console.WriteLine("Filesizeinbytes:{0}",f.Length);
Console.WriteLine("Filecreationtime:{0}",f.CreationTime);

}
}

TheOutputandexplanation
ThiswastheoutputIgotonmymachine.

F:c#files>files1
abouttoreadfileusingStreamReader.ReadLine()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Heynow!Heynow!
Iko,Iko,unday
Jockamofeenoainanay?
Jockamofeenanay?

abouttoreadfileusingBinaryReader.ReadByte()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
H.e.y..n.o.w.!..H.e.y..n.o.w.!.
I.k.o.,..I.k.o.,..u.n.d.a.y.
J.o.c.k.a.m.o..f.e.e.n.o..a.i..n.a.n..a.y.?.
J.o.c.k.a.m.o..f.e.e..n.a.n..a.y.?.

PrintsomeinfoonourfileusingtheFileclass
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Filename:nish.txt
Filenameinfull:F:c#files
ish.txt
Filesizeinbytes:83
Filecreationtime:10/13/012:18PM

F:c#files>

不可能天天有学习.net),我一同学说,你应该早就有作品啦。我惶惶然……
沙发
发表于 2015-1-20 05:33:07 | 只看该作者
ASP是把代码交给VBScript解释器或Jscript解释器来解释,当然速度没有编译过的程序快了。
深爱那片海 该用户已被删除
板凳
发表于 2015-1-27 14:52:53 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码。
若天明 该用户已被删除
地板
发表于 2015-2-5 07:14:20 | 只看该作者
Servlet的形式和前面讲的CGI差不多,它是HTML代码和后台程序分开的。它们的启动原理也差不多,都是服务器接到客户端的请求后,进行应答。不同的是,CGI对每个客户请求都打开一个进程(Process)。
若相依 该用户已被删除
5#
发表于 2015-2-11 07:45:20 | 只看该作者
逐步缩小出错代码段的范围,最终确定错误代码的位置。
活着的死人 该用户已被删除
6#
发表于 2015-3-1 23:39:27 | 只看该作者
可以通过在现有ASP应用程序中逐渐添加ASP.NET功能,随时增强ASP应用程序的功能。ASP.NET是一个已编译的、基于.NET的环境,可以用任何与.NET兼容的语言(包括VisualBasic.NET、C#和JScript.NET.)创作应用程序。另外,任何ASP.NET应用程序都可以使用整个.NETFramework。开发人员可以方便地获得这些技术的优点,其中包括托管的公共语言运行库环境、类型安全、继承等等。
admin 该用户已被删除
7#
发表于 2015-3-11 01:03:48 | 只看该作者
大哥拜托,Java在95年就出来了,微软垄断个妹啊,服务器市场微软完全是后后来者,当年都是Unix的市场,现在被WindowsServer和Linux抢下大片,包括数据库也一样。
只想知道 该用户已被删除
8#
发表于 2015-3-17 17:11:06 | 只看该作者
由于CGI程序每响应一个客户就会打开一个新的进程,所以,当有多个用户同时进行CGI请求的时候,服务器就会打开多个进程,这样就加重了服务器的负担,使服务器的执行效率变得越来越低下。
乐观 该用户已被删除
9#
发表于 2015-3-24 15:26:18 | 只看该作者
比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-7 06:29

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表