`
wfdoublext
  • 浏览: 126181 次
  • 性别: Icon_minigender_1
  • 来自: 青岛
社区版块
存档分类
最新评论

read file directory

    博客分类:
  • .net
阅读更多
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 BusinessMonthPlan
{
	/// <summary>
	/// WebForm4 の概要の説明です。
	/// </summary>
	public class WebForm4 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.ListBox FileList;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Button Button3;
		protected string CurrentPath;
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(Page.IsPostBack==false)
 			{
  			CurrentPath= @"c:\UserDir"; //?置当前目?
				int aa=CurrentPath.IndexOf(".");
  			if(Directory.Exists(@"c:\UserDir")==false) //若?目?不存在,?建?目?
   			Directory.CreateDirectory(@"c:\UserDir");
   			LoadDir(CurrentPath); //初始化装入目?

 			}

		}
		private void LoadDir(string FullPath)
		{
 			CurrentPath=FullPath;
 			ArrayList values = new ArrayList();
 			string [] MyFiles,MyDirs;
 			MyFiles = Directory.GetFiles(FullPath); //得到?目?下所有文件
 			if(CurrentPath!=@"c:\UserDir") //若不是??目?,增加“返回上?目?”?? 

 			values.AddRange(MyFiles); //加入文件
 			MyDirs= Directory.GetDirectories(FullPath); //得到?目?下所有目?
 			values.AddRange(MyDirs); //加入目?
 			FileList.DataSource=values; //?置数据源
 			FileList.DataBind(); //?定数据
		}



		private void Button1_Click(object sender, System.EventArgs e)
		{
			//if(FileList.SelectedItem.Text=="返回上?目?") //返回上?目?
 			//{
  			//string ParentPath1=Directory.GetParent(CurrentPath).ToString();
				string ParentPath=this.FileList.SelectedItem.Text.ToString();
				Session["aa"]=ParentPath;
  			LoadDir(ParentPath);
  			return;
 			//}
 			//else //打?目?

		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			//string aa=1;
			//string ParentPath=this.FileList.SelectedItem.Text.ToString();
			string aa;
			aa=Directory.GetCurrentDirectory().ToString();

			string ParentPath1=Directory.GetParent(aa).ToString();
			
			
				
  			LoadDir(ParentPath1);
  			return;
		}

		private void Button3_Click(object sender, System.EventArgs e)
		{
		
			//string ParentPath=this.FileList.SelectedItem.Text.ToString();
			string aa;
			aa=@"C:\UserDir\aa\新しいフォルダ";

			string ParentPath1=Directory.GetParent(Session["aa"].ToString()).ToString();
			
			Session["aa"]=ParentPath1;

  			LoadDir(ParentPath1);
  			return;
		}

		private void FileList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string ParentPath=this.FileList.SelectedItem.Text.ToString();
			Session["aa"]=ParentPath;
  			LoadDir(ParentPath);
  			return;
		}
	}
}

 

分享到:
评论

相关推荐

    无法打开包括文件 gl glaux.h No such file or directory

    error C1083: 无法打开包括文件:“gl\GLAux.h”: No such file or directory 原来是:#include 出错 ==================================================== 解决方法如下: 1:下载此资源包 2:【glaux.dll】 复制...

    read-file-tree:递归读取目录中所有文件的内容

    npm install read-file-tree 用法 var readFileTree = require ( 'read-file-tree' ) readFileTree ( '/path/to/directory' , function ( err , tree ) { console . log ( tree ) } ) 原料药 readFileTree(basedir...

    File_实用案例_实现文件拷贝_FileCopy.java

    // looping until we reach the end of the file (when read() returns // -1). Note the combination of assignment and comparison in this // while loop. This is a common I/O programming idiom. while(...

    Active Directory Cookbook, 3rd Edition.pdf

    Covers how to back up Active Directory, perform authoritative and nonauthoritative restores, check DIT file integrity, perform online and offline defrags, and search for deleted objects. Chapter 17, ...

    oracle中utl_file包读写文件操作实例学习

    在oracle中utl_file包提供了一些操作... –给用户授权 grant read, write on directory TESTFILE to zxx; 详细介绍 http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm 2.写入操作 代码如下

    ftplib-4.0

    FTP Library Routines Release 4.0 ...FtpRead() - Read from remote file or directory FtpWrite() - Write to remote file FtpClose() - Close data connection Utilities qftp - Command line ftp utility

    cmake之file命令:文件处理命令

     1.1 READ  1.2 STRINGS  1.3 HASH  1.4 TIMESTAMP  1.5 GET_RUNTIME_DEPENDENCIES 2. 写(Writing)  2.1 WRITE和APPEND  2.2 TOUCH和TOUCH_NOCREATE  2.3 GENERATE  2.4 CONFIGURE 3....

    HyperledgerFabric问题及解决.txt

    UTC [main] main -&gt; ERRO 001 Cannot run peer because error when setting up MSP from directory Error:can't read the block:&{SERVICE_UNAVAILABLE} Error:Error endorsing chaincode:rpc error:code = ...

    scjp(310-065 part2)

    Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: 1. import java.io.*; 2. public class Maker{ 3. public static...

    RobotFramework中SSHLibrary学习与总结.pdf

    File Should Not Exist, Directory Should Exist , Directory Should Not Exist 2.2 List Directory, List Files In Directory , List Directories In Directory 2.3 Put Directory ,Get Directory,Put File,Get ...

    PETools源码

    PEfile.Read(&ImpDescriptor;,20); if (ImpDescriptor.Name==NULL) { break; } else { NameRaw=ImpDescriptor.Name-ImpRVA+ImpRaw; PEfile2.Seek(NameRaw,CFile::begin); for(j=0;j;j++){ PEfile2.Read(&...

    squashfs1.3r3.tar.gz

    exlude files/directories from the specified exclude file, one file/directory per line. If an exclude file/directory is absolute (i.e. prefixed with /, ../, or ./) the entry is treated as absolute, ...

    ip包分析

    named ReadIP0802.pch and a precompiled types file named StdAfx.obj. Resource.h This is the standard header file, which defines new resource IDs. Microsoft Visual C++ reads and updates this file....

    武汉大学计算机学院 陈刚 unix

    If target is a directory, tcp will copy source into this directory. EXAMPLES The following examples show common usage: tcp file1 file2 tcp file1 dir tcp file1 dir/file2 tcp file1 dir/subdir/subsubdir/...

    武汉大学unix第一次上机实验作业

    If target is a directory, tcp will copy source into this directory. EXAMPLES The following examples show common usage: tcp file1 file2 tcp file1 dir tcp file1 dir/file2 tcp file1 dir/subdir/subsubdir/...

    esp32 TCP DEMO

    是在官方的SDK下进行简单的添加TCP协议。实现TCP连接服务器。

    DBA常用命令

    SQL&gt; grant read,write on directory external_2 to hr; 3. sql&gt;conn hr/hr 4. 创建外部表 create table extab_test3 (id number,name varchar2(20)) organization external (type oracle_loader default ...

    mqrt.dll文件

    2. Move the dll file to the program directory missing the file. 3. If step 2 doesn't work. Move mqrt.dll to the system directory. Windows Install - Windows 95,98, and Me - C:\Windows\System - ...

    squashfs2.2-r2.tar.gz

    SQUASHFS 2.2 - A squashed read-only filesystem for Linux ...exlude files/directories from the specified exclude file, one file/directory per line. If an exclude file/directory is absolute (i.e. prefixed...

    C# 打包 zip

    ZipInputStream s = new ZipInputStream(File.OpenRead(filePath1)); ZipEntry theEntry; while ((theEntry = s.GetNextEntry()) != null) { string fullname = Server.MapPath("ziptemp/" + urlid + "/" + the...

Global site tag (gtag.js) - Google Analytics