w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

jsp cannot write file out of permission denial on webapps but /tmp directory?
String filePath = application.getRealPath("/WEB-INF/bbs/" + filename); Just a guess, fact that you're trying to write /WEB-INF implies WEB-INF is at the root of your drive.

Categories : Jsp

Does fsync of a parent directory guarantee synchronization of meta data of all recursive sub directories?
When fsync is called on a directory the operation treats its target more like a file than a container of files. From the file system's perspective a directory is a special kind of file that just happens to contain metadata about other files. When fsync is applied to a directory, this metadata about the contained files is synchronized but not the subdirectories/files themselves. If you want to ensure that all of the contents are properly synchronized, then you should fsync them explicitly.

Categories : Android

Python module needs to write files to a directory but permission is blocked
Application data should be stored under either %APPDATA%, $XDG_CONFIG_HOME, or ~/.config, depending on the platform. Create a directory for the module within one of those locations. Or better yet, have the application tell you where your data should be located.

Categories : Python

Unix script to recursively search a directory and sub directories to grep and print content between 2 patterns in file
This might work for you: find . -type f -exec awk 'BEGING {print FILENAME ":"} /Pattern1/ { p=1 ; next } /Pattern2/ {p=0} p==1 {print $0} END {print ""}' {} ; Note, this prints the FILENAME, even if Pattern1 was not found!

Categories : Unix

how to search for a file in directory and sub directories basing on the file name in ssis
The Foreach Loop Container is a powerful construct in your SSIS toolbox. If you use the File Enumerator, which is the default, you can specify Where to start, What to look for How to retrieve the location Search subfolders What to look for Currently displayed as *.txt indicates that all files ending in .txt are an acceptable match. As @lamak has commented, if you have a requirement to only find files that start with something, then you would change the value to MyFilePrefix*.txt That would match files files C:ssisdataOperationsInputMyFilePrefix_20130618.txt C:ssisdataOperationsInputSubFolderMyFilePrefix_20130618.txt C:ssisdataOperationsInputSubFolderSubSubfolderMyFilePrefix.txt while excluding things such as C:ssisdataOperationsMyFilePrefix_20130618.txt C:ssisdataOperations

Categories : SQL

How do I enumerate through a directory in Objective-C, and essentially clear out all the directories of non-directory files?
Something like this will work: NSURL *rootURL = ... // File URL of the root directory you need NSFileManager *fm = [NSFileManager defaultManager]; NSDirectoryEnumerator *dirEnumerator = [fm enumeratorAtURL:rootURL includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey] options:NSDirectoryEnumerationSkipsHiddenFiles errorHandler:nil]; for (NSURL *url in dirEnumerator) { NSNumber *isDirectory; [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL]; if (![isDirectory boolValue]) { // This is a file - remove it [fm removeItemAtURL:url error:NULL]; } }

Categories : Objective C

Copy files from source directory to target directory and exclude specific file types from specified directories
This is one way to do it $SourceDirectory = 'C:Source' $DestinationDirectory = 'C:Destination' $ExcludeExtentions = '*.txt*', '*.xml*' $ExcludeSubDirectory = 'C:Sourcead_directory1', 'C:Sourcead_directory2' Get-ChildItem $SourceDirectory -Recurse -Exclude $ExcludeExtentions | Where-Object { $ExcludeSubDirectory -notcontains $_.DirectoryName } | Copy-Item -Destination $DestinationDirectory Your best friend here is Where-Object, or where. It takes a scriptblock as parameter and uses that scriptblock to validate each object that goes through pipeline. Only objects that make script return $true are passed through Where-Object. Also, take a look at the object that represents a file you get from Get-ChildItem. It has Name, Directory and DirectoryName containing pieces of file's FullNam

Categories : File

Linux: Set permission only to directories
Use find to search for directories and apply chmod on them: find -type d | xargs chmod 775 Use type f for file: find -type f | xargs chmod 775

Categories : Linux

How to provide permission access to directories and files in windows-phone-8
Windows Phone applications can only access files in their own sandboxed area of "isolated storage". It is not possible to access, change or modify files or folders outside this area. There is no way to share files via the file system. If you can let us know what you are trying to ultimately achieve then we may be able to suggest an alternative.

Categories : Windows Phone 8

How to access a file in a directory from other directory, when both are in same parent directory with HTML
if dir1 and dir2 are in the same parent directory then this is how you access 2.html from 1.html: <a href="../dir2/2.html">link to 2.html</a> hope it helped :)

Categories : HTML

While creating the directory I'm getting some sub directories instead?
Specify the format of the string representation of your date time: DateTime.Now.ToString("dd-MM-yy"); See MSDN - Custom Date and Time Format Strings for more info!

Categories : C#

Get all directories within directory nodejs
This should do it: fs = require 'fs' getDirs = (rootDir) -> files = fs.readdirSync(rootDir) dirs = [] for file in files if file[0] != '.' filePath = "#{rootDir}/#{file}" stat = fs.statSync(filePath) if stat.isDirectory() dirs.push(file) return dirs async version: fs = require 'fs' getDirs = (rootDir, cb) -> fs.readdir rootDir, (err, files) -> dirs = [] for file, index in files if file[0] != '.' filePath = "#{rootDir}/#{file}" fs.stat filePath, (err, stat) -> if stat.isDirectory() dirs.push(file) if files.length == (index + 1) cb(dirs) js vers

Categories : Node Js

How to loop through parent directories in php?
Try to create a recursive function like this function getSomeFile($path) { if(file_exists($path) { return file_get_contents($path); } else { return getSomeFile("../" . $path); } }

Categories : PHP

Python joining current directory and parent directory with os.path.join
You can use normpath, realpath or abspath: import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_dir # prints C:/here/I/am/../../my_dir print os.path.normpath(goal_dir) # prints C:/here/my_dir print os.path.realpath(goal_dir) # prints C:/here/my_dir print os.path.abspath(goal_dir) # prints C:/here/my_dir

Categories : Python

.htaccess redirect all sub directories under sub directory
Give this a try: <IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^windows/([^/]+)/?$ /windows/ct.php?ct=$1 [L] </IfModule> For your localhost use this one: <IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase /Site/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^windows/([^/]+)/?$ windows/ct.php?ct=$1 [NC,L] </IfModule>

Categories : Htaccess

Trying to remove a file and its parent directories
This would be a safer way: find /my/path/ -mindepth 2 -maxdepth 2 -type f -name 'README.txt' -mtime +30 -printf '%h ' | xargs echo rm -r Remove echo if you find it already correct after seeing the output. With that you use printf '%h ' to get the directory of the file, then use xargs to process it.

Categories : Bash

Get parent directory's parent directory name in java
Have a look at http://developer.android.com/reference/java/io/File.html#getParentFile() Applying this twice will probably get you the right directory. But note that you program might or might not be allowed to go there, based on the settings in the file system and the context your code runs in.

Categories : Java

Rename the pdf file inside sub-directories to the name of the sub directory
@ECHO OFF &SETLOCAL for /F "delims=" %%a in ('dir /b /s /a-d *.pdf') do ( set "fname=%%~fa" for %%b in ("%%~dpa.") do set "nname=%%~nxb" setlocal enabledelayedexpansion ECHO ren "!fname!" "!nname!.pdf" endlocal ) Note: you can rename only one pdf/folder. Some other code for the OP: @ECHO OFF &SETLOCAL MKDIR "H:Myfolder est" for /f "delims=" %%i in ('DIR /b /a-d "H:Myfolder"') do ( ECHO %%i CD "H:Myfolder\%%~i" ren *.pdf "%%~nxi.pdf" copy *.pdf "H:Myfolder est" cd H:Myfolder ) cd H:Myfolder est del H:Myfolder est est.pdf

Categories : Batch File

counting number of directories in a specific directory
find is also printing the directory itself: $ find .vim/ -maxdepth 1 -type d .vim/ .vim/indent .vim/colors .vim/doc .vim/after .vim/autoload .vim/compiler .vim/plugin .vim/syntax .vim/ftplugin .vim/bundle .vim/ftdetect You can instead test the directory's children and do not descend into them at all: $ find .vim/* -maxdepth 0 -type d .vim/after .vim/autoload .vim/bundle .vim/colors .vim/compiler .vim/doc .vim/ftdetect .vim/ftplugin .vim/indent .vim/plugin .vim/syntax $ find .vim/* -maxdepth 0 -type d | wc -l 11 $ find .vim/ -maxdepth 1 -type d | wc -l 12 You can also use ls: $ ls -l .vim | grep -c ^d 11 $ ls -l .vim total 52 drwxrwxr-x 3 anossovp anossovp 4096 Aug 29 2012 after drwxrwxr-x 2 anossovp anossovp 4096 Aug 29 2012 autoload drwxrwxr-x 13 anossovp anossovp 4096 Aug 2

Categories : Linux

How can I list files and directories with them directory levels
I think you can use file path as key and level number as value using dictionary. and parse the file path string to calculate level number, use string.split string[] words = s.Split('\');

Categories : C#

Linux zip a directory excluding some internal directories
It's not an error, it's a warning. Archives containing absolute paths to files are a security risk. Imagine an archive containing /etc/passwd. If you insist upon having the absolute paths in the archive, use the -P option: -P, --absolute-names don't strip leading `/'s from file names

Categories : Linux

Add write permission and keep gid
man 2 chmod has this to say: If the calling process is not privileged (Linux: does not have the CAP_FSETID capability), and the group of the file does not match the effective group ID of the process or one of its supplementary group IDs, the S_ISGID bit will be turned off, but this will not cause an error to be returned. I am guessing that git is not in the apache group, so when git changes the mode on the directory, the setgid bit is automatically cleared. You can either add git to the apache group, or use a privileged account to do the chmod.

Categories : Misc

read and write files to different directories Python
You probably want to check the directory the file is operating within or check the current working directory: import os cur_dir= os.getcwd() top_dir = os.path.dirname(cur_dir) # perform operations in current directory # do some stuff in top directory

Categories : Python

How to output CSS files to single directory from several input directories?
Consider creating a sass directory with dummy files for each of your components: project/ css/ foo.css bar.css baz.css modules/ foo/ foo.scss bar/ bar.scss baz/ baz.scss sass/ foo.scss bar.scss baz.scss Each dummy file should import the corresponding component. sass/foo.scss: @import "../modules/foo/foo.scss"; When you have all dummy files set up, run sass --update sass:css from the root of your project.

Categories : CSS

Copy a single file to all sub directories under a certain directory using Ant Script
The following example uses the groovy ANT task. Example ├── build.xml ├── lib │   └── groovy-all-2.1.6.jar ├── src │   └── index.html └── target └── DirectoryA ├── index.html ├── SubdirectoryAA │   └── index.html └── SubdirectoryAB ├── index.html └── SubdirectoryABA └── index.html build.xml <project name="demo" default="copy"> <path id="build.path"> <pathelement location="lib/groovy-all-2.1.6.jar"/> </path> <target name="copy"> <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/> <dirset id="trgDirs" dir="ta

Categories : PHP

python walk directory tree with excluding certain directories
root gives the entire path and not just the root from where you started. The docs makes it a bit more clear to what it's doing: for dirpath, dirnames, filenames in os.walk('/usr/lib'): print dirpath See the docs here

Categories : Python

I'm trying to compress some files from one directory to another but I'm getting access denied on one of the directories why?
It doesn't work because you pass a directory name for the second parameter to CompressDirectory. You should pass a file name like.... string output = Path.Combine(zippedFileDirectory, "MyZipFile.7z"); ..... compressor.CompressDirectory(source, output);

Categories : C#

Batch Command to Move Files from Sub Directories to New Directory
Try using For /F "TOKENS=1 DELIMS=%_TabSpace%" %%B In ('dir %1 /a-d /S /B /OD') DO ( the /s will cause recursion. The downside is that the output of the dir command is then d:pathfile.ext - which may not marry well with your "TOKENS=1 DELIMS=%_TabSpace%". You'd probably need to use "delims=" (ie, no delimiters, hence entire line in token1). You can then retrieve the various parts of the full-filename as %%~dB, %%~pB, %%~nB and %%~xB (the drive, path, naem and extension - and you can combine these parts if you wish by using %%~nxB for name+extension, for instance. Supplemental info - batch commented. @ECHO OFF SETLOCAL :: The above two lines are a traditional batch introduction. :: The first turns `ECHO`ing of the command to the console OFF :: The second makes all changes to the en

Categories : Windows

Replace multiple files in sub directories with file from a different directory
try this: cd /d "C:Users----DocumentsTrainRuns" FOR /D /R %%a IN (*) do if exist "%%~a est1.hfl" echo copy /y "test1.hfl" "%%~a" Look at the output and remove the word echo if it looks good. Accepting an answer - how does it work?

Categories : Windows

NSFileManager list directory contents excluding directories
You can go a little deeper with a directory enumerator. How about this? NSDirectoryEnumerator *dirEnumerator = [localFileManager enumeratorAtURL:directoryToScan includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLNameKey, NSURLIsDirectoryKey,nil] options:NSDirectoryEnumerationSkipsSubdirectoryDescendants errorHandler:nil]; NSMutableArray *theArray=[NSMutableArray array]; for (NSURL *theURL in dirEnumerator) { // Retrieve the file name. From NSURLNameKey, cached during the enumeration. NSString *fileName; [theURL getResourceValue:&fileName forKey:NSURLNameKey error:NULL]; // Retrieve whether a directory. From NSURLIsDirectoryKey, also // cached during the enumeration. NSNumber *isDirectory; [theURL getResourceValue:&isDirectory forKey:NSURL

Categories : Objective C

Recursive Search of Directories php
Your loop appears to be running away with itself when the opendir fails. You may try testing the return value like so: if(!($handle= opendir($directory))) { echo "Could not opendir($directory) "; return false; }

Categories : PHP

Search all differences between two directories
Try one of the GUI replacements of diff like KDiff3. UPDATE You might want to try and take a look at mtree.

Categories : Linux

How to redirect all sub-directory pages to parent directory?
Add this to your .htaccess file RedirectMatch 301 ^/folder/$ http://example.com/folder What this basically does in corresponding to your question is redirect anything (be it sub directories, or files) inside the folder directory to your parent folder.

Categories : PHP

How to print the name of my current directory's parent directory
You can use ${PWD%/*}: $ echo $PWD /home/me/test/t $ echo ${PWD%/*} /home/me/test As the expression ${string%substring} Strips shortest match of $substring from back of $string (reference).

Categories : Shell

How to write a portable program in python that accesses particular directories?
I would use the user's home folder and use the os.path module. Let's say you have a program named myapp and a database called db.sqlite. import os.path path = os.path.expanduser('~/.myapp/db.sqlite') path would then be expanded to /home/user/.myapp/db.sqlite on a UNIX-based system (and similar for Mac) and C:UsersuserApplication DataRoaming.myappdb.sqlite (or something similar, not on a windows machine) on a Windows machine.

Categories : Python

Write Permission issue on PHP
7 - owner bits, read/write/execute 5 - group bits, read/execute 5 - everyone else bits, read/execute Since the file is 755, only the owner has write permissions. You've got apache running as apache, and the file is owned by root, so the owners don't match, and you end up with no write permissions. You'd probably want to chown the file to apache:web-content or at least root:web-content and make the file 575 instead, so that the group permissions match up.

Categories : PHP

searching for values stored in an arraylist through all the files within a directory and its sub directories
List all the files in a directory. `public void listFilesAndFilesSubDirectories(String directoryName){ File directory = new File(directoryName); //get all the files from a directory File[] fList = directory.listFiles(); for (File file : fList){ if (file.isFile()){ System.out.println(file.getAbsolutePath()); } else if (file.isDirectory()){ listFilesAndFilesSubDirectories(file.getAbsolutePath()); } } }` Now loop through your list of files reading each one. Now iterate the list containing the words, check with each word. If you find the word, add the file name in another list. See to that you iterate the file in the outer loop and the word inside the file loop.

Categories : Java

PHP FILES Recursive backup of directories, deleting main directory
As shown from your function-output, the directories are not empty. I suppose that the data is of low value and just needs to be backed up. I assume you are running Linux from your choice of a slash rather than a backslash. Naturally directories incur links or inodes, with metadata, which in linux can be checked via df -hi The Inode-Ids of files can be shown via the -i flag of ls ls -i filename ls -iltr ls -ltri `echo $HOME` Inodes take up space, and introduce overhead in file-system operations. So much to the motivation to remove the directories. PHP's rmdir function to remove directories requires that The directory must be empty, and the relevant permissions must permit this. It is also non-recursive. Approach 1: flatten filenames and move the files to a backup directory, t

Categories : PHP

Non recursive makefile for manu sources directories with flat .obj directory
Simply include a makefile that create explicit dependencies: # Makefile OBJ_DIR:=objects SRC_FILES := $(notdir $(SRCS)) all: $(SRC_FILES:%.c=$(OBJ_DIR)/%.o) tmp_srcs := $(SRCS) include $(foreach dummy, $(SRCS), object_rule.mk) $(OBJ_DIR)/.sentinel: mkdir -p $(dir $@) && touch $@ The trick is in the combination of the include statement and a foreach. The foreach will generate as many "object_rule.mk" as there are files listed in SRCS. The included makefile, object_rule.mk simply generates the object rule for the corresponding source file like this: ifeq (,$(tmp_srcs)) $(error this makefile requires the variable tmp_srcs to be set) endif src_path:=$(word 1, $(tmp_srcs)) ifeq (1, $(words $(tmp_srcs))) tmp_srcs:= else tmp_srcs:=$(wordlist 2, $(words $(tmp_srcs)), $(tmp_src

Categories : C

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.