首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

吞红钢碳自残在线求问:如何调用不了CS文件啊

2012-01-30 
吞红钢碳自残在线求问:怎么调用不了CS文件啊?我有一个aspx文件和一个CS文件:aspx文件:%@PageLanguage C

吞红钢碳自残在线求问:怎么调用不了CS文件啊?
我有一个aspx文件和一个CS文件:
aspx文件:
<%@   Page   Language= "C# "   ContentType= "text/html "   ResponseEncoding= "gb2312 "   Inherits= "HandleEvent "   Src= "test.aspx.cs "   AutoEventWireup= "false "   Debug= "true "%>
<%@   Import   NameSpace= "System.IO "%>
<%@   Import   NameSpace= "System.Data "%>
<%@   Import   NameSpace= "System.Data.SqlClient "%>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 复制删除整个文件夹 </title>
</head>
<body>
    <form   runat= "server ">
        <asp:Button   ID= "cp "   runat= "server "   Text= "拷贝文件夹 "/>
    </form>
</body>
</html>
==========================================
CS文件:
    using   System;
    using   System.Data;
    using   System.Collections;
    using   System.Data.SqlClient;
    using   System.Web.UI;
    using   System.Web.UI.HtmlControls;
    using   System.Web.UI.WebControls;
    public   class   HandleEvent   :   Page
    {
        public   void   Page_Load(Object   src,EventArgs   e)
        {
if(Page.IsPostBack)
{
string   images=Server.MapPath( "images/ ");
        string   news=Server.MapPath( "news/ ");
        Move(images,news);
Response.Write( " <script   language=javascript> alert( '复制文件夹成功! '); </ "+ "script> ");
}
        }
    }
    private   void   Move(string   oldp,string   newp)
    {
if(!System.IO.Directory.Exists(newp))
{
System.IO.Directory.CreateDirectory(newp);
}
if(!System.IO.Directory.Exists(newp))
{
return;
}
string[]   files   =   Directory.GetFiles(oldp);
string[]   dirs   =   Directory.GetDirectories(oldp);
if(files   !=   null   &&   files.Length   > 0)
{
for(int   i=0;i <files.Length;i++)
{
File.Copy(files[i],newp+ "\\ "+(new   System.IO.FileInfo(files[i]).Name),true);
}
}
if(dirs   !=   null   &&   dirs.Length   > 0)
{
for(int   i=0;i <dirs.Length;i++)
{
if(!System.IO.Directory.Exists(dirs[i]))
{
System.IO.Directory.CreateDirectory(newp+ "\\ "+new   System.IO.DirectoryInfo(dirs[i]).Name);
}
Move(dirs[i],newp+ "\\ "+new   System.IO.DirectoryInfo(dirs[i]).Name);
}
}
    }
=======================
以上为两个文件100%完整的代码~
我想在aspx文件中调用cs文件中的Move函数,但是我按aspx文件中的调用方法( <%@   Page   Language= "C# "   ContentType= "text/html "   ResponseEncoding= "gb2312 "   Inherits= "HandleEvent "   Src= "test.aspx.cs "   AutoEventWireup= "false "   Debug= "true "%>
)来运行aspx文件就报错!
报错信息如下:
Compiler   Error   Message:   CS0116:   A   namespace   does   not   directly   contain   members   such   as   fields   or   methods



Source   Error:

 

Line   19:           }
Line   20:       }
Line   21:       private   void   Move(string   oldp,string   newp)(←此行为报错行~)
Line   22:       {
Line   23:   if(!System.IO.Directory.Exists(newp))
 
这是一个简单的问题~但是本人很菜~所以在这请教下各位高手~火红的钢碳还在我嘴你含着的...在线狂等答案~+_+

[解决办法]
我感觉你的那个move应该写在 class 里面,也就是写成
public partial class text : System.Web.UI.Page
{
public void Page_Load(Object src, EventArgs e)
{
……………………
}
private void Move(string oldp, string newp)
{
…………………………
}
}
我这样试了下,那一行没有问题了,但是还有其他的问题。(我也是菜鸟,互相学习)

热点排行