How can I find the size of all files located inside a folder?

How about letting OS do it for you: long long int getFolderSize(string path) { // command to be executed std::string cmd(“du -sb “); cmd.append(path); cmd.append(” | cut -f1 2>&1″); // execute above command and get the output FILE *stream = popen(cmd.c_str(), “r”); if (stream) { const int max_size = 256; char readbuf[max_size]; if (fgets(readbuf, max_size, … Read more

How can I display images from a specific folder on android gallery

Hi you can use the code below, i hope it helps you . package com.example.browsepicture; import java.io.File; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.media.MediaScannerConnection; import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class BrowsePicture2 extends Activity { String SCAN_PATH; File[] allFiles ; public void onCreate(Bundle savedInstanceState) { … Read more

Best way to iterate folders and subfolders

If you’re using .NET 4, you may wish to use the System.IO.DirectoryInfo.EnumerateDirectories and System.IO.DirectoryInfo.EnumerateFiles methods. If you use the Directory.GetFiles method as other posts have recommended, the method call will not return until it has retrieved ALL the entries. This could take a long time if you are using recursion. From the documentation: The EnumerateFilesand … Read more

Batch create folders based on part of file name and move files into that folder

@ECHO OFF SETLOCAL SET “sourcedir=c:\sourcedir” PUSHD %sourcedir% FOR /f “tokens=1*” %%a IN ( ‘dir /b /a-d “*_*_*-*-* *.*”‘ ) DO ( ECHO MD %%a ECHO MOVE “%%a %%b” .\%%a\ ) POPD GOTO :EOF This should accomplish the required task – or at least show the required instructions. If you are satisfied with the commands issued, … Read more