获取指定资源目录下的所有文件的方法

使用前需要引入System.IO;这个命名空间

第一种方法:

 1 public void GetFiles()
 2 {
 3     //路径 
 4     string path = string.Format("{0}", @"D:\SHU170221U3D-09\Lesson14\Assets\BundleFiles");
 5 
 6     //获取指定后缀名文件
 7     //var files = Directory.GetFiles(path, "*.manifest");
 8 
 9     //获取所有文件
10     var files = Directory.GetFiles(path);
11     foreach (var file in files)
12     {
13         Debug.Log(file);
14     }
15 }

这种方法只能获取到文件,不能获取到文件的具体信息。

第二种方法:

 1 public void GetFiles()
 2 {
 3     //路径 
 4     string path = string.Format("{0}", @"D:\SHU170221U3D-09\Lesson14\Assets\BundleFiles");
 5 
 6     DirectoryInfo folder = new DirectoryInfo(path);
 7 
 8     //获取指定后缀名文件
 9     //foreach (FileInfo file in folder.GetFiles("*.manifest"))
10     //{
11     //    Debug.Log(file.Name);
12     //    Debug.Log("FullName:" + file.FullName);
13     //    Debug.Log("DirectoryName:" + file.DirectoryName);
14     //}
15 
16     //获取所有文件
17     foreach (FileInfo file in folder.GetFiles())
18     {
19         Debug.Log(file.Name);
20         Debug.Log("FullName:" + file.FullName);
21         Debug.Log("DirectoryName:" + file.DirectoryName);
22     }
23 }

这种方法可以获取到文件的所有信息。

 

转载于:https://www.cnblogs.com/AaronBlogs/p/6838523.html

得到指定文件夹内所有文件名及路径 得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径得到指定文件夹内所有文件名及路径 立即下载

相关推荐

命令行下获取远程FTP目录文件

前提:已获知FTP的相关登录信息 介绍:该脚本是为解决相关工程定时同步获取ftp相关文件而编写的;简单高效,并且可行。需要下载资源的同学自行修改相关IP、用户名/密码、指定文件名以及相关路径 使用方法: (1)运行FtpCommand.bat (2)再运行GetFtpCMBKEY.bat

获取 /resources 目录资源文件的 9 种方法(抄的)

项目开发中,经常会有一些静态资源,被放置在resources目录下,随项目打包在一起,代码中要使用的时候,通过文件读取的方式,加载并使用;来源:https://blog.csdn.net/u011047968/article/details/107311462。本文中汇总整理了九种方式获取resources目录下文件的方法。

weixin_44887276的博客 2734

OpenPose 论文理解

OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation paper: Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields link: OpenPose paper...

JustForYou的博客 2万+

Java 获取指定目录下的所有文件和目录

Java 获取指定目录下的所有文件和目录 前言 本片我将为大家讲解如何获取用户输入的文件路径,获取指定路径以及路径下所有的文件和目录,而且可以统计文件和目录的数量。 提示:以下是本篇文章正文内容,下面案例可供参考 一、主要的类 其实涉及到文件和目录,一般都是与Java的IO类相关的,但是本章却没有涉及到IO,而是涉及到了另一个类File。他可以对我们的文件和目录进行管理。 java.io.File类主要用于描述文件或目录路径的抽象表示信息,可以获取文件或目录的特征信息,如:大小等。 二、实现代码 2

云梦归遥【qq_45834685】 1万+

Solidworks钣金设计:折弯系数、K因子与折弯扣除的实战应用解析

本文深入解析Solidworks钣金设计中折弯系数、K因子与折弯扣除的核心概念与实战应用。通过厘清三者间的逻辑关系与换算方法,并结合材料特性、工艺参数及车间实测,指导工程师精准确定展开长度,确保设计图纸与加工实物的一致性,有效提升钣金件设计精度与生产效率。

weixin_29268267的博客 937

java获取文件夹下所有的文件

java获取文件夹下所有的文件,文件名,递归

qq_46258463的博客 5万+

开关电源环路补偿--开关电源进阶知识补充1

笔记 一 . 做开关电源环路补偿时候为了使得环路更加稳定。 1 .-- > 希望开关电源的相位裕量在45° 以上, 2. – > 希望开关电源的增益裕量在10db 以上 3. – > 希望开关电源增益曲线在过0db 时候以20db /dec 斜率下降(体现1个极点) 4. – > 希望开关电源补偿之后的带宽达到开关频率的是1/5 ~1/10,用以原理开关电源的开关噪音。 左边图示电源瞬态拉载和释放负载的时候输出电压存在明显的振铃,说明这个目前的环路相位裕量(phase m

qq_29776365的博客 1万+

Python小技巧【1】——获取指定文件夹下的所有文件【glob模块】

glob模块是Python标准库中一个重要的模块,主要用来查找符合特定规则的目录和文件,并将搜索的到的结果返回到一个列表中。

规划GIS会 5481

Ubuntu使用cmake出现Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed

解决 Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed

qq_44225529的博客 1万+

Error: Flash Download failed - Target DLL has been cancelled

由于换了新电脑,keil重装了下,然而之前的MCU的支持包没有安装,以及一些其他的问题,导致可以编译但是不能将程序烧录到单片机中。现整理一下解决思路: 1、将支持包下载并添加: 找到你需要用的MCU的具体型号: 例如: 点击网址,下载安装包,或者在csdn等其他网址下载安装包,将下载好的pack包放到keil5的安装目录下的.Download中: 点击file中的import,将路径选择到.........

hanhan的博客 5万+

unity 获取选中的目录_Unity 获取指定资源目录下的所有文件

获取 所有资源[@MenuItem("Navy/Assets/Test")]static void Test_Compoent(){//OK//这个不好用~//Debug.Log(AssetDatabase.LoadAllAssetsAtPath("Assets/Models/21/21000001/21000001.prefab").Length);//设置进度条EditorUtility.Di...

weixin_30746095的博客 1519

ROCm rocr-libhsakmt分析系列9-3: queue的内核创建流程

KFD队列是用户空间与GPU通信的核心机制,通过多种队列类型(计算、DMA、调试等)实现命令流管理。核心数据结构包括描述队列属性的queue_properties、内核调度对象queue、进程级管理器process_queue_manager,以及跨进程设备的qcm_process_device等。这些结构通过ring buffer、doorbell机制和MQD硬件描述符协同工作,支持队列全生命周期管理、资源调度、异常处理和上下文保存/恢复功能。

图形/计算GPU的驱动与虚拟化技术分享园地 2159

Unity 获取指定资源目录下的所有文件

获取 所有资源 [@MenuItem("Navy/Assets/Test")] static void Test_Compoent(){ //OK //这个不好用~ //Debug.Log(AssetDatabase.LoadAllAssetsAtPath("Assets/Models/21/21000001/21000001.prefab").Length); //设置进度

花、sir的专栏 2万+

微信小程序:errno: 600001, errMsg: “uploadFile:fail errcode:-101 cronet_error_code:-10001 error_msg:net::E

微信小程序报错uploadFile:fail errcode:-101 cronet_error_code:-10001 error_msg:net::ERR_CONNECTION_RESET, custum ip is invalid, didn't find user's ip,wx.uploadFile errno: 600001 errcode:-101 ?微信小程序wx.uploadFile错误,wx.uploadFile 在真机上报下面的错误,调试工具里没有问题,其它接口在真机/调试工具都正常,

✅ 精选推荐文章 4269

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

获取resources目录下的指定文件可以通过多种方式实现

在Java中,获取resources目录下的指定文件可以通过多种方式实现。这里我将详细介绍如何使用类加载器()和类对象(Class)来获取资源文件,并提供一些示例代码。

qq_33240556的博客 1021

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

SpringBoot 项目将文件图片资源上传到本地静态资源文件夹下(指定文件夹下)

1、SpringBoot 项目将文件图片资源上传到本地静态资源文件夹下(指定文件夹下) 最终效果: 前端浏览本地文件,点击上传至本地resources/static/images/imgWall下 2、实现流程 1.构造前端页面的表单,需要注意的是< form >标签的属性设置enctype=“multipart/form-data”,以及提交方式设置为post <form action="#" th:action="@{/admin/upload}" method="post" enc

zouyang920的博客 8424

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

解决java工程打包后无法找到资源文件路径的方法

问题描述: 一般情况下我们希望将一些固定的资源文件通过eclipse一起导出到一个jar包中。例如以下的一个工程资源布局: 此工程到处以后红色部分是不会导入到jar包里面的,而绿色部分是可以导入到jar包里的。 那么利用资源时在代码中使用相对路径比如读红色部分file中的file.txt文件使用  String path = “file/file.txt”; 是没有问题的。但是打

leon90dm的专栏 1万+

获取指定目录下的文件

String projectPath = Constants.class.getResource("/").getFile();   int findindex = projectPath.indexOf("WEB-INF"); projectPath = projectPath.substring(1, findindex + 8)+"workflow/"+workflowpath; Fi

leading_the_way的专栏 284

Android复制Assets目录下的文件到指定目录

1 package com.android.demo; 2 3   import java.io.File; 4   import java.io.FileOutputStream; 5   import java.io.InputStream; 6   import android.content.Context; 7   public clas...

angen3675的博客 375

TDirectory.GetDirectories获取子目录及文件

和 TDirectory.GetFiles 用法一样, TDirectory.GetDirectories 是用来获取子目录的. 另外还有 TDirectory.GetFileSystemEntries 可同时获取文件与子目录, 用法都一样. unit Unit1; interface uses   Windows, Messages, SysUtils,

pdw2009的专栏 5144

SpringBoot项目打成jar包后上传文件到服务器 目录与jar包同级问题

看标题好像很简单的样子,但是针对使用jar包发布SpringBoot项目就不一样了。 当你使用tomcat发布项目的时候,上传文件存放会变得非常简单,因为你可以随意操作项目路径下的资源。但是当你使用SpringBoot的jar包发布项目的时候,你会发现,你不能像以前一样操作文件了。当你使用File file = new File()的时候根本不知道这个路径怎么办。而且总不能很小的项目也给它构建一...

4448
上一篇: Unity获取指定资源目录下的所有文件
下一篇: Unity对象查找
ddry47579
博客等级 码龄12年 10粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值