吞红钢碳自残在线求问:怎么调用不了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