http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A

解决方案 »

  1.   

    <%@ Page language="c#" Codebehind="DiskManage.aspx.cs" AutoEventWireup="false" Inherits="BaseFrameWork.WebSetting.NetWork.DiskManage" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>DiskManage</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <BODY background="images/bk1.jpg" MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <table id="Table1" style="Z-INDEX: 101; LEFT: 8px; WIDTH: 570px; POSITION: absolute; TOP: 8px; HEIGHT: 376px"
    cellSpacing="0" cellPadding="0" width="570" border="0">
    <TR>
    <TD noWrap>
    <TABLE id="Table2" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <TR>
    <TD noWrap></TD>
    </TR>
    <TR>
    <TD noWrap>
    <TABLE id="Table3" cellSpacing="0" cellPadding="0" width="300" border="0">
    <TR>
    <TD style="WIDTH: 359px; HEIGHT: 1px" noWrap><FONT face="宋体">网络硬盘</FONT></TD>
    </TR>
    <TR>
    <TD style="WIDTH: 359px; HEIGHT: 135px" noWrap>
    <asp:ListBox id="lstMenu" runat="server" Height="128px" Width="448px"></asp:ListBox></TD>
    </TR>
    <TR>
    <TD style="WIDTH: 359px" noWrap align="center"><FONT face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </FONT>
    <asp:Button id="btnLoad" runat="server" Text="下载"></asp:Button>
    <asp:Button id="btnDel" runat="server" Text="删除"></asp:Button></TD>
    </TR>
    <TR>
    <TD style="WIDTH: 359px" noWrap><INPUT id="webOpen" style="WIDTH: 312px; HEIGHT: 22px" type="file" size="32" name="webOpen"
    runat="server">
    <asp:Button id="btnUp" runat="server" Text="上传"></asp:Button></TD>
    </TR>
    <TR>
    <TD style="WIDTH: 359px" noWrap>
    <asp:TextBox id="txtCreateMenu" runat="server" Width="240px"></asp:TextBox><FONT face="宋体"></FONT>
    <asp:Button id="btnCreateMenu" runat="server" Width="55px" Text="新建目录"></asp:Button></TD>
    </TR>
    <TR>
    <TD style="WIDTH: 359px" noWrap>
    <asp:Label id="lblMsg" runat="server" Width="152px"></asp:Label></TD>
    </TR>
    </TABLE>
    </TD>
    </TR>
    <TR>
    <TD noWrap></TD>
    </TR>
    </TABLE>
    </TD>
    </TR>
    </table>
    &nbsp;
    </form>
    </BODY>
    </HTML>
      

  2.   

    用我下面的吧
    上面那个麻烦了点
    <%@ Page language="c#" Codebehind="NetWorkDisk.aspx.cs" AutoEventWireup="false" Inherits="csFileUp.NetWorkDisk" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>NetWrokDisk</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout" background="bk1.jpg">
    <form id="Form1" method="post" runat="server" EncType="multipart/form-data">
    <asp:ListBox id="FileList" style="Z-INDEX: 102; LEFT: 125px; POSITION: absolute; TOP: 137px" runat="server" Height="155px" Width="575px" BackColor="Transparent"></asp:ListBox>
    <asp:CheckBox id="chkHidden" style="Z-INDEX: 114; LEFT: 572px; POSITION: absolute; TOP: 369px" runat="server" Text="隐藏"></asp:CheckBox>
    <asp:CheckBox id="chkReadOnly" style="Z-INDEX: 113; LEFT: 508px; POSITION: absolute; TOP: 369px" runat="server" Text="只读"></asp:CheckBox>
    <DIV style="Z-INDEX: 112; LEFT: 213px; WIDTH: 315px; POSITION: absolute; TOP: 33px; HEIGHT: 81px" ms_positioning="FlowLayout"><FONT face="宋体">
    <P><FONT face="方正舒体" color="#ff9900" size="5"><STRONG>网络硬盘</STRONG></FONT></P>
    <P><FONT face="方正舒体" color="#ff9900" size="5"><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    --您的个人移动秘书</STRONG></FONT></P>
    </FONT>
    </DIV>
    <asp:Label id="Label3" style="Z-INDEX: 111; LEFT: 52px; POSITION: absolute; TOP: 142px" runat="server">目录浏览:</asp:Label>
    <asp:Label id="Label2" style="Z-INDEX: 110; LEFT: 51px; POSITION: absolute; TOP: 371px" runat="server">目录新建:</asp:Label>
    <asp:Label id="Label1" style="Z-INDEX: 109; LEFT: 52px; POSITION: absolute; TOP: 339px" runat="server">文件上传:</asp:Label>
    <asp:Button id="BtnUpload" style="Z-INDEX: 108; LEFT: 638px; POSITION: absolute; TOP: 336px" runat="server" Text="上  传" Width="68px"></asp:Button>
    <INPUT runat="server" style="Z-INDEX: 107; LEFT: 131px; WIDTH: 490px; POSITION: absolute; TOP: 336px; HEIGHT: 22px" type="file" size="62" id="WebFile" name="WebFile">
    <asp:Button id="BtnOpen" style="Z-INDEX: 106; LEFT: 313px; POSITION: absolute; TOP: 299px" runat="server" Text="打开"></asp:Button>
    <asp:Button id="BtnDelete" style="Z-INDEX: 105; LEFT: 501px; POSITION: absolute; TOP: 298px" runat="server" Text="删除"></asp:Button>
    <asp:Label id="Info" style="Z-INDEX: 104; LEFT: 54px; POSITION: absolute; TOP: 111px" runat="server" ForeColor="Red"></asp:Label>
    <asp:Button id="BtnNewDir" style="Z-INDEX: 103; LEFT: 639px; POSITION: absolute; TOP: 369px" runat="server" Text="新建目录" Width="70px"></asp:Button>
    <asp:TextBox id="NewDirName" style="Z-INDEX: 101; LEFT: 132px; POSITION: absolute; TOP: 368px" runat="server" Width="366px"></asp:TextBox>
    </form>
    </body>
    </HTML>
      

  3.   

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.IO;namespace csFileUp
    {
    /// <summary>
    /// WebForm1 的摘要说明。
    /// </summary>
    public class NetWorkDisk : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.ListBox FileList;
    protected System.Web.UI.WebControls.Button BtnNewDir;
    protected System.Web.UI.WebControls.TextBox NewDirName;
    protected System.Web.UI.WebControls.Label Info;
    protected System.Web.UI.WebControls.Button BtnDelete;
    protected System.Web.UI.WebControls.Button BtnOpen;
    protected System.Web.UI.WebControls.Button BtnUpload;
    protected System.Web.UI.HtmlControls.HtmlInputFile WebFile;
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.Label Label2;
    protected System.Web.UI.WebControls.Label Label3;
    protected System.Web.UI.WebControls.CheckBox chkReadOnly;
    protected System.Web.UI.WebControls.CheckBox chkHidden;
    private static string CurrentPath;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if( Page.IsPostBack==false)
    {
    CurrentPath= @"c:\UserDir\";  //设置当前目录
    if(Directory.Exists(@"c:\UserDir\")==false) //若该目录不存在,创建该目录
    Directory.CreateDirectory(@"c:\UserDir\");
    LoadDir(CurrentPath);  //初始化装入目录
    }
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.BtnUpload.Click += new System.EventHandler(this.BtnUpload_Click);
    this.BtnOpen.Click += new System.EventHandler(this.BtnOpen_Click);
    this.BtnDelete.Click += new System.EventHandler(this.BtnDelete_Click);
    this.BtnNewDir.Click += new System.EventHandler(this.BtnNewDir_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion //装入目录
    private void LoadDir(string FullPath)
    {
    CurrentPath=FullPath;
    ArrayList values = new ArrayList();
    string [] MyFiles,MyDirs;
    MyFiles = Directory.GetFiles(FullPath);  //得到该目录下所有文件
    if(CurrentPath!=@"c:\UserDir")  //若不是顶级目录,增加返回上级目录选项
    {
    values.Add("返回上级目录");
    }
    values.AddRange(MyFiles);  //加入文件
    MyDirs= Directory.GetDirectories(FullPath);  //得到该目录下所有目录
    values.AddRange(MyDirs);  //加入目录 FileList.DataSource=values;  //设定数据源
    FileList.DataBind();  //绑定数据
    } //新建目录
    private void BtnNewDir_Click(object sender, System.EventArgs e)
    {
    string FullDirName = CurrentPath + @"\" + NewDirName.Text;   //生成完整路径
                if(NewDirName.Text=="")
    {
    Info.Text="请先输入要创建的新文件夹名";
    return;
    }
    try
    {
    if(Directory.Exists(FullDirName))
    {
    Info.Text="已存在该文件夹,请更换名称";
    return;
    }
    DirectoryInfo DirInfo = Directory.CreateDirectory(FullDirName);  //创建目录
    if (chkReadOnly.Checked==true)
    {
    if(chkHidden.Checked==false)
    DirInfo.Attributes = FileAttributes.ReadOnly;
    else
    DirInfo.Attributes = FileAttributes.ReadOnly|FileAttributes.Hidden;
    }
    else
    {
    if(chkHidden.Checked==true)
    DirInfo.Attributes = FileAttributes.Hidden;
    }

    LoadDir(CurrentPath);  //重新载入当前目录
    }
    catch
    {
    Info.Text="创建文件夹失败,请与管理员联系";
    }
    } //文件下载
    private void FileDownload(string FullFileName)
    {
    FileInfo DownloadFile = new FileInfo(FullFileName); 
    Response.Clear();
    Response.ClearHeaders();
    Response.Buffer=false;
    Response.ContentType="application/octet-stream";
    Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.ASCII));
    Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
    Response.WriteFile(DownloadFile.FullName);
    Response.Flush();
    Response.End();
    } //删除
    private void DeleteThings(string FullPath)
    {
    if(FullPath.IndexOf(".")>0) //删除文件
    {
    File.Delete(FullPath);
    LoadDir(CurrentPath);  //重新载入当前目录
    }
    else    //删除目录
    {
    Directory.Delete(FullPath); 
    LoadDir(CurrentPath); //重新载入当前目录
    }
    } private void BtnDelete_Click(object sender, System.EventArgs e)
    {
    DeleteThings(FileList.SelectedItem.Text);
    } //打开文件或目录
    private void BtnOpen_Click(object sender, System.EventArgs e)
    {
    if(FileList.SelectedItem.Text=="返回上级目录")   //返回上级目录
    {
    string ParentPath=Directory.GetParent(CurrentPath).ToString(); LoadDir(ParentPath);
    return;
    }
    else if(FileList.SelectedItem.Text.IndexOf(".")>0) //打开文件
    {
    FileDownload(FileList.SelectedItem.Text);

    else    //打开目录
    {
    LoadDir(FileList.SelectedItem.Text);
    }
    } //文件上传
    private void BtnUpload_Click(object sender, System.EventArgs e)
    {
    if(WebFile.PostedFile.FileName=="")
    {
    Info.Text="请先选择要上传的文件";
    return;
    } try
    {
    char[] spliter = {'\\'};
    string [] FileName = WebFile.PostedFile.FileName.Split(spliter,10); string FullPath = CurrentPath + @"\" + FileName[FileName.Length-1];  //生成完整文件名
    WebFile.PostedFile.SaveAs(FullPath);  //保存文件
    LoadDir(CurrentPath);  //重新载入当前目录
    }
    catch
    {
    Info.Text="上传文件失败,请与管理员联系";
    }
    } }
    }
      

  4.   

    C#来开发一客户端,最好考虑一下ftp上传,