directory

How to .gitignore all files/folder in a folder, but not the folder itself? [duplicate]

夙愿已清 提交于 2019-12-28 01:39:12
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I add an empty directory to a git repository I want to check in a blank folder. How can I do this? 回答1: You can't commit empty folders in git. If you want it to show up, you need to put something in it, even just an empty file. For example, add an empty file called .gitkeep to the folder you want to keep, then in your .gitignore file write: # exclude everything somefolder/* # exception to the rule

成功解决NotFoundError (see above for traceback): Failed to create a directory: ; No such file or directo

荒凉一梦 提交于 2019-12-27 22:56:37
成功解决NotFoundError (see above for traceback): Failed to create a directory: ; No such file or directo 目录 解决问题 解决方法 解决问题 NotFoundError (see above for traceback): Failed to create a directory: ; No such file or directory [[Node: save/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/SaveV2/tensor_names, save/SaveV2/shape_and_slices, Variable, Variable/Adam, Variable/Adam_1, Variable_1, Variable_1/Adam, Variable_1/Adam_1, Variable_2,

How can I get the size of a folder on SD card in Android?

风格不统一 提交于 2019-12-27 20:07:09
问题 Is it possible to easily get the size of a folder on the SD card? I use a folder for caching of images, and would like to present the total size of all cached images. Is there a way to this other than iterating over each file? They all reside inside the same folder? 回答1: Just go through all files and sum the length of them: /** * Return the size of a directory in bytes */ private static long dirSize(File dir) { if (dir.exists()) { long result = 0; File[] fileList = dir.listFiles(); for(int i

iOS App 升级时文件的保留情况

早过忘川 提交于 2019-12-27 14:22:33
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 有这样一个问题,用户用iOS设备下载了大量的数据,保存在设备本地,如果用户升级了应用本身,这些文件是否仍然存在。 找了一些官方解释和Stackflow上的说明 Where You Should Put Your App’s Files To prevent the syncing and backup processes on iOS devices from taking a long time, be selective about where you place files inside your app’s home directory. Apps that store large files can slow down the process of backing up to iTunes or iCloud. These apps can also consume a large amount of a user's available storage, which may encourage the user to delete the app or disable backup of that app's data to iCloud. With this in mind, you should

How can I use PHP to check if a directory is empty?

China☆狼群 提交于 2019-12-27 13:04:37
问题 I am using the following script to read a directory. If there is no file in the directory it should say empty. The problem is, it just keeps saying the directory is empty even though there ARE files inside and vice versa. <?php $pid = $_GET["prodref"]; $dir = '/assets/'.$pid.'/v'; $q = (count(glob("$dir/*")) === 0) ? 'Empty' : 'Not empty'; if ($q=="Empty") echo "the folder is empty"; else echo "the folder is NOT empty"; ?> 回答1: It seems that you need scandir instead of glob, as glob can't see

Getting all file names from a folder using C# [duplicate]

纵饮孤独 提交于 2019-12-27 11:54:10
问题 This question already has answers here : How to recursively list all the files in a directory in C#? (19 answers) Closed 6 years ago . I wanted to know if it is possible to get all the names of text files in a certain folder. For example, I have a folder with the name Maps, and I would like to get the names of all the text files in that folder and add it to a list of strings. Is it possible, and if so, how I can achieve this? 回答1: DirectoryInfo d = new DirectoryInfo(@"D:\Test");//Assuming

Directory 与 DirectoryInfo 的区别

爱⌒轻易说出口 提交于 2019-12-27 11:02:06
Directory 与 DirectoryInfo 这两个能够实现大多数相同的功能。区别可分为两点: 一、静态与实例调用 前者必须被实例化后才能使用,而后者则只提 供了静态的方法。如果多次使用某个对象一般使用前者; 如果仅执行某一个操作则使用后者提供的静态方法效率更 高一些。 Directory 可直接调用,不需要实例化,比如 Directory.Delete(path)。 DirectoryInfo 必须实例化才能调用其方法,在频繁地操作某一目录时,这种方式比较方便。 二、功能多少 DirectoryInfo 的功能要稍微比 Directory 多些、强些,比如 DirectoryInfo 的 GetFiles 返回的是 FileInfo[],而 Directory.GetFiles 返回的是 string[]。 来源: https://www.cnblogs.com/diaomin/p/5542871.html

文件及IO操作(一)

二次信任 提交于 2019-12-27 10:54:03
文件及IO操作(二) 文件及IO操作(三) 1、File和FileInfo表示文件系统上的文件 2、Directory和DirectoryInfo表示文件系统上的文件夹 3、Path 表示路径,可以用来处理物理路径 Directory和File它们是静态成员,只含静态的方法,不能够被实例化;(当用一次两次时用,如果多次操作的话就不好了) DirectoryInfo和FileInfo 要实例化的对象(它们可以用于多次操作) File 操作 文件是否存在 if (File.Exists(path)) { Console.WriteLine("不存在该文件"); } 创建文件: File.Create(@"e:\2.txt"); 复制文件: File.Copy(@"e:\1.txt",@"e:\2.txt"); 删除文件: File.Delete(@"e:\1.txt"); 移动相当于剪切( 类似于复制一份到2.txt,在把1.txt删除 ): File.Move(@"e:\1.txt", @"e:\2.txt"); 获取文件和目录的属性: FileAttributes fs = File.GetAttributes(@"e:\1.txt"); Console.WriteLine(fs); 返回指定文件或目录的日期和时间: 1 DateTime dt1 = File

List all files in one directory PHP [duplicate]

无人久伴 提交于 2019-12-27 10:42:58
问题 This question already has answers here : Getting the names of all files in a directory with PHP (15 answers) PHP list all files in directory [duplicate] (5 answers) Closed 6 years ago . What would be the best way to list all the files in one directory with PHP? Is there a $_SERVER function to do this? I would like to list all the files in the usernames/ directory and loop over that result with a link, so that I can just click the hyperlink of the filename to get there. Thanks! 回答1: Check this

Directory-tree listing in Python

余生颓废 提交于 2019-12-27 08:56:47
问题 How do I get a list of all files (and directories) in a given directory in Python? 回答1: This is a way to traverse every file and directory in a directory tree: import os for dirname, dirnames, filenames in os.walk('.'): # print path to all subdirectories first. for subdirname in dirnames: print(os.path.join(dirname, subdirname)) # print path to all filenames. for filename in filenames: print(os.path.join(dirname, filename)) # Advanced usage: # editing the 'dirnames' list will stop os.walk()