directory

How do I detect when a directory or file changes without constant scanning

天大地大妈咪最大 提交于 2019-12-17 09:33:59
问题 Other than reading all the files and comparing them with a previous snapshot, is there a way to detect when a directory changes in C# with Windows? I don't mind PInvoke if that's what it takes. EDIT The FileSystemWatcher class is great, but one gotcha is that you must kick off any work in the callback notification to a background task/thread to avoid blocking which will cause dropped events. 回答1: Use the FileSystemWatcher class - it does what you want. It won't tell you which bytes in the

FileUriExposedException in Android [duplicate]

a 夏天 提交于 2019-12-17 07:49:34
问题 This question already has answers here : android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData() (24 answers) Closed 3 months ago . I need to open folder in internal storage that contains images. I use following code. Java File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyPhotos"); Intent intent = new Intent(Intent.ACTION_VIEW); String path =folder.getPath(); Uri myImagesdir =

How to list all folder with size via batch file

时光怂恿深爱的人放手 提交于 2019-12-17 07:38:43
问题 I want a simple solution for list of folders and size of them in either txt or csv format. I use this code for folder list dir C:\Temp\*.* /b /a:d > C:\folderList.txt current output <<folderList.txt>> folder1 folder2 folder3 desired output <<folderList.txt>> folder1 # 100 MB folder2 # 30 MB folder3 # 110 MB Simply it would generate the size of each folder.. How can I proceed?? any help 回答1: For each folder in the list, use dir command to retrieve the size of the files under the folder @echo

How to list all folder with size via batch file

﹥>﹥吖頭↗ 提交于 2019-12-17 07:34:59
问题 I want a simple solution for list of folders and size of them in either txt or csv format. I use this code for folder list dir C:\Temp\*.* /b /a:d > C:\folderList.txt current output <<folderList.txt>> folder1 folder2 folder3 desired output <<folderList.txt>> folder1 # 100 MB folder2 # 30 MB folder3 # 110 MB Simply it would generate the size of each folder.. How can I proceed?? any help 回答1: For each folder in the list, use dir command to retrieve the size of the files under the folder @echo

Get location of JAR file

坚强是说给别人听的谎言 提交于 2019-12-17 07:31:18
问题 I'm trying to get the location a Runnable JAR file is run from. I tried doing try { String path = new java.io.File(".").getCanonicalPath(); } catch (IOException e) { e.printStackTrace(); } But that returns: C:\Users\Kevin\Desktop/server/Server while the JAR file is located at C:\Users\Kevin\Desktop I also tried doing return new file(Server.class.getProtectionDomain().getCodeSource().getLocation().getPath()); But that returns: C:\Users\Kevin\Desktop\server.jar/server/Server So basicly I want

How to get the newest file in a directory in php

∥☆過路亽.° 提交于 2019-12-17 07:30:35
问题 So I have this app that processes CSV files. I have a line of code to load the file. $myFile = "data/FrontlineSMS_Message_Export_20120721.csv"; //The name of the CSV file $fh = fopen($myFile, 'r'); //Open the file I would like to find a way in which I could look in the data directory and get the newest file (they all have date tags so they would be in order inside of data ) and set the name equal to $myFile . I really couldn't find and understand the documentation of php directories so any

Maven - how to include empty directories

给你一囗甜甜゛ 提交于 2019-12-17 07:27:20
问题 By default during the build process maven is removing the empty directories. Do you know if a parameter can be specified in the pom to instruct maven to include empty directories in the generated target/test-classes folder? 回答1: According to this ticket MRESOURCES-36, there should be a <includeEmptyDirs> element, but only for Maven Resources Plugin 2.3. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.3</version> <configuration>

How does git handle folder permission?

浪尽此生 提交于 2019-12-17 07:25:33
问题 I'm using git version 1.5.6.3, and it seems git doesn't notice a folder's mode changes #create a test repository with a folder with 777 mode :~$ mkdir -p test/folder :~$ touch test/folder/dummy.txt :~$ cd test :~/test$ chmod 777 folder/ #init git repository :~/test$ git init Initialized empty Git repository in ~/test/.git/ :~/test$ git add . :~/test$ git commit -m 'commit a directory' Created initial commit 9b6b21a: commit a directory 0 files changed, 0 insertions(+), 0 deletions(-) create

Renaming multiple files in a directory using Python

半腔热情 提交于 2019-12-17 06:38:30
问题 I'm trying to rename multiple files in a directory using this Python script: import os path = '/Users/myName/Desktop/directory' files = os.listdir(path) i = 1 for file in files: os.rename(file, str(i)+'.jpg') i = i+1 When I run this script, I get the following error: Traceback (most recent call last): File "rename.py", line 7, in <module> os.rename(file, str(i)+'.jpg') OSError: [Errno 2] No such file or directory Why is that? How can I solve this issue? Thanks. 回答1: You are not giving the

How to select a directory and store the location using tkinter in Python

拥有回忆 提交于 2019-12-17 06:36:28
问题 I am creating a GUI with a browse button which I only want to return the path. I've been looking at solutions using code like below. Tkinter.Button(subframe, text = "Browse", command = self.loadtemplate, width = 10).pack() def loadtemplate(self): filename = tkFileDialog.askopenfilename(filetypes = (("Template files", "*.tplate") ,("HTML files", "*.html;*.htm") ,("All files", "*.*") )) if filename: try: self.settings["template"].set(filename) except: tkMessageBox.showerror("Open Source File",