Search Results

Search found 14344 results on 574 pages for 'path'.

Page 139/574 | < Previous Page | 135 136 137 138 139 140 141 142 143 144 145 146  | Next Page >

  • Improve performance of sorting files by extension

    - by DxCK
    With a given array of file names, the most simpliest way to sort it by file extension is like this: Array.Sort(fileNames, (x, y) => Path.GetExtension(x).CompareTo(Path.GetExtension(y))); The problem is that on very long list (~800k) it takes very long to sort, while sorting by the whole file name is faster for a couple of seconds! Theoretical, there is a way to optimize it: instead of using Path.GetExtension() and compare the newly created extension-only-strings, we can provide a Comparison than compares starting from the LastIndexOf('.') without creating new strings. Now, suppose i found the LastIndexOf('.'), i want to reuse native .NET's StringComparer and apply it only to the part on string after the LastIndexOf('.'). Didn't found a way to do that. Any ideas?

    Read the article

  • Remove empty subfolders with PHP

    - by Dmitry Letano
    I am working on a PHP function that will recursively remove all sub-folders that contain no files starting from a given absolute path. Here is the code developed so far: function RemoveEmptySubFolders($starting_from_path) { // Returns true if the folder contains no files function IsEmptyFolder($folder) { return (count(array_diff(glob($folder.DIRECTORY_SEPARATOR."*"), Array(".", ".."))) == 0); } // Cycles thorugh the subfolders of $from_path and // returns true if at least one empty folder has been removed function DoRemoveEmptyFolders($from_path) { if(IsEmptyFolder($from_path)) { rmdir($from_path); return true; } else { $Dirs = glob($from_path.DIRECTORY_SEPARATOR."*", GLOB_ONLYDIR); $ret = false; foreach($Dirs as $path) { $res = DoRemoveEmptyFolders($path); $ret = $ret ? $ret : $res; } return $ret; } } while (DoRemoveEmptyFolders($starting_from_path)) {} } As per my tests this function works, though I would be very delighted to see any ideas for better performing code.

    Read the article

  • VBScript - copy files modified in last 24 hours

    - by Martin North
    Hi, I'm trying to copy files from a directory where the last modified date is within 24hours of the current date. I'm using a wildcard in the filepath as it changes every day I'm using; option explicit dim fileSystem, folder, file dim path path = "d:\x\logs" Set fileSystem = CreateObject("Scripting.FileSystemObject") Set folder = fileSystem.GetFolder(path) for each file in folder.Files If DateDiff("d", file.DateLastModified, Now) < 1 Then filesystem.CopyFile "d:\x\logs\apache_access_log-*", "d:\completed logs\" WScript.Echo file.Name & " last modified at " & file.DateLastModified end if next Unfortunately this seems to be copying all files, and not just the recently modified ones. Can anyone point me in the right direction? many thanks Martin.

    Read the article

  • PHP: deleting files – permission denied – chmod?

    - by mathiregister
    hi guys, i want to delete files from a directory via php. Somehow my php_errorlog always tells me: [06-Jun-2010 19:38:46] PHP Warning: chmod() [function.chmod]: Operation not permitted in /Users/myname/htdocs/ if ($_POST) { echo "yeah!!!"; print count($_POST['deletefiles']); chmod($path, 0777); //server rights foreach ($_POST['deletefiles'] as $value) { print $value; unlink($path .'/' . $value); } //chmod($path, 0666); //server rights } what am I doing wrong? Thank you

    Read the article

  • Newbie Question: Read and Process a List of Text Files

    - by johnv
    I'm completely new to .NET and am trying as a first step to write a text processing program. The task is simple: I have a list of 10,000 text files stored in one folder, and I'm trying to read each one, store it as a string variable, then run it through a series of functions, then save the final output to another folder. So far I can only manage to manually input the file path like this (in VB.NET): Dim tRead As System.IO.StreamReader Public Function ReadFile() As String Dim EntireFile As String tRead = File.OpenText("c:\textexample\00001.txt") EntireFile = tRead.ReadToEnd Return EntireFile End Function Public Function Step1() ..... End Function Public Function Step2() ..... End Function .............. I'm wondering, therefore, if there's a way to automate this process. Perhaps for example store all input file path into a text file then read each entry at a time, then save the final output into the save path, again listed in a text file. Any help is greatly appreciated. ReplyQuote

    Read the article

  • unsupported major .minor version 51.0

    - by ERJAN
    I am trying to use notepad++ as my all-in-one tool edit, run, compile etc. I have jre installed, i have setup my path variable to .../bin directory. When I run my "Hello world" in notepad++ , I get this message: java.lang.UnsupportedClassVersionError: test_hello_world : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) ......................................... I think the problem here is about versions, some version of java may be old or too new. how do i fix it? should i install jdk , and setup my path variable to JDK instead of jre? difference between PATH variable in jre or jdk?

    Read the article

  • How can I use IndexOf to pick a specific Character when there are more than one of them?

    - by JimDel
    How can I use IndexOf with SubString to pick a specific Character when there are more than one of them? Here's my issue. I want to take the path "C:\Users\Jim\AppData\Local\Temp\" and remove the "Temp\" part. Leaving just "C:\Users\Jim\AppData\Local\" I have solved my problem with the code below but this assumes that the "Temp" folder is actually called "Temp". Is there a better way? Thanks if (Path.GetTempPath() != null) // Is it there?{ tempDir = Path.GetTempPath(); //Make a string out of it. int iLastPos = tempDir.LastIndexOf(@"\"); if (Directory.Exists(tempDir) && iLastPos > tempDir.IndexOf(@"\")) { // Take the position of the last "/" and subtract 4. // 4 is the lenghth of the word "temp". tempDir = tempDir.Substring(0, iLastPos - 4); }}

    Read the article

  • Setting an ASIHTTPRequest post to a SimpleHTTPServer Python server?

    - by Rob
    I am working on a project (that i will not be releasing to the app store - just for fun) that will upload an image via an HTTP Post request from my iPhone to a server that I have running the Python script SimpleHTTPServer. I have successfully used the ASIHTTP APIs in the past for text strings, but can't for the life of me figure out how to upload an image. I have tried all of the following: NSString *path = [[NSBundle mainBundle] pathForResource:@"Image" ofType:@".png"]; [request setFile:@"Image.png" forKey:@"file"]; [request setFile:path forKey:@"file"]; [request setFile:path withFileName:@"Image.png" andContentType:@"image/jpeg" forKey:@"file"]; [request setData:[UIImage imageNamed:@"Image.png"] withFileName:@"Image.png" andContentType:@"Image" forKey:@"file"]; Any thoughts on where i could be going wrong?

    Read the article

  • Python: Importing a file from a parent folder

    - by Sascha
    ...Now I know this question has been asked many times & I have looked at these other threads. Nothing so far has worked, from using sys.path.append('.') to just import foo I have a python file that wishes to import a file (that is in its parent directory). Can you help me figure out how my child file can successfully import its a file in its parent directory. I am using python 2.7 The structure is like so (each directory also has the __init__.py file in it): StockTracker/ __Comp/ ____a.py ____SubComp/ ______b.py Inside b.py, I would like to import a.py: So I have tried each of the following but I still get an error inside b.py saying "There is no such module a" import a import .a import Comp.a import StockTracker.Comp.a import os import sys sys.path.append('.') import a sys.path.remove('.')

    Read the article

  • Logical python question - handeling directories and files in them

    - by Konstantin
    Hello! I'm using this function to extract files from .zip archive and store it on the server: def unzip_file_into_dir(file, dir): import sys, zipfile, os, os.path os.makedirs(dir, 0777) zfobj = zipfile.ZipFile(file) for name in zfobj.namelist(): if name.endswith('/'): os.mkdir(os.path.join(dir, name)) else: outfile = open(os.path.join(dir, name), 'wb') outfile.write(zfobj.read(name)) outfile.close() And the usage: unzip_file_into_dir('/var/zips/somearchive.zip', '/var/www/extracted_zip') somearchive.zip have this structure: somearchive.zip 1.jpeg 2.jpeg another.jpeg or, somethimes, this one: somearchive.zip somedir/ 1.jpeg 2.jpeg another.jpeg Question is: how do I modify my function, so that my extracted_zip catalog would always contain just images, not images in another subdirectory, even if images are stored in somedir inside an archive.

    Read the article

  • saving appengine mail from spam filters

    - by Fh
    One of my clients uses Trend Micro InterScan Messaging Security to protect their internal mail services. Suddenly InterScan decided to filter out all messages coming from Google App Engine. Unfortunately they haven't been able to whitelist the sender address as each e-mail gets a different one. For example, *3ckihSOVMMHlZHSL.JSMMHlZHSL.JS*@apphosting.bounces.google.com, with everything before the @ being variable. Update I'm including this screenshot of how Interscan sees the incoming e-mail. Notice that all senders are different: If I look into the e-mail headers, the apphosting domain appears inside the Return-Path field: Return-Path: <36kSiSwYIBh0883XL3E7.5EH883XL3E7.5E@apphosting.bounces.google.com> The "From" field looks ok. It says what I set it to say, but the spam filter only looks at the Return-Path. My client sysadmin doesn't want to whitelist the whole apphosting domain, as it wouldn't be only whitelisting my application. How could I bypass this e-mail filters if I can't get an unique sender? Thanks,

    Read the article

  • How do I shorten the repository URL using svn+ssh similar to svnserve -r?

    - by Marcus
    In the svnbook, it shows you how to shorten the URL to your repositories when using svnserve as a daemon, using -r like: svnserve -d -r /usr/local/repositories That way, you can refer to the repository you need right after the hostname in the URL without revealing any of the local path (which is /usr/local/repositories/project1): svn checkout svn://host.example.com/project1 However, now that I am switching to svn+ssh, I have the local path back in my repository URL: svn checkout svn+ssh://host.example.com/usr/local/repositories/project1 Does anyone know how to hide that local path and use a shorter URL as up above, using svn+ssh and WITHOUT using a UNIX soft link on the svn server? (you still end up with an extra string in the URL if you use a soft link...) UPDATE: The solution to this can be found in the accepted answer over on ServerFault (the green-checked answer). Yay!

    Read the article

  • is it possible if callback in array_filter receive parameter ?

    - by justjoe
    i got this multiple array name $files[], who consist keys and values as below : [0] = Array ( [name] = index1.php [path] = http://localhost/php/gettingstarted/ [number] = 1 ) [1] = Array ( [name] = index10.php [path] = http://localhost/php/gettingstarted/ [number] = 2 ) [2] = Array ( [name] = index11.php [path] = http://localhost/php/gettingstarted/ [number] = 3 ) and i use this code to create new array consist of 'name' keys only. but it failed array_filter($files, "is_inarr_key('name')"); function is_inarr_key($array, $key) { //TODO : remove every array except those who got the same $key } and i got this error array_filter() [function.array-filter]: The second argument, 'is_inarr_key('name')', should be a valid callback in C:\xampp\htdocs\php\gettingstarted\index.php on line 15 so the queastion : 1. is it possible to make call-back function on array_filter has ability to receive parameter ? What is general rule of thumb on how to use callback in anyPHP built-in function ?

    Read the article

  • NSIS already installed product

    - by Buba235
    Hello! I have some problem with my created nsis setup. I need to check if the product is already installed and then get the path to the already installed product. This is because I want to build a "Feature-Setup" that installs some other components into the previous installed folder. Does anyone know how to build this installer? It will be brilliant if the feature setup will start the installation and check the path of the installed product. After checking is done the path should be (read only) in "Destination Folder" under "Choose Install Location". Thanks for any help Buba

    Read the article

  • What would be the right way to declare an array within a script that will be called by cron?

    - by Nano Taboada
    I've written a Korn Shell script that sets an array the following way: set -A fruits Apple Orange Banana Strawberry but when I'm trying to run it from within cron, it raises the following error: Your "cron" job on myhost /myScript.sh produced the following output: myScript.sh: -A: bad option(s) I've tried many crontab syntax variants, such as: Attempt 1: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/myScript.sh Attempt 2: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/./myScript.sh Attempt 3: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ./myScript.sh Any workaround would be sincerely appreciated. Thanks much in advance!

    Read the article

  • Adding custom validator without using Zend_Form's addElementPrefixPath

    - by nush
    The problem is that I don't use Zend_Form, so I can't use the built in capabilities. I usually look for three things when setting a validator: - its path (usually in library/path/validators/MyValidator.php) - its class name (tried Validators_MyValidator) and - in application.ini, the autoloaderNamespaces[] = "Validators" I've tried different settings/namings/layouts to no avail. When using a validator in my Zend_Validate_Input, an exception occurs, saying that it couldn't find my plugin/validator, the classes being searched only in Zend/Validate with the Zend_Validate prefix (I didn't try this prefix, though). Wasn't there a setting in app.ini that added a prefix and a path?

    Read the article

  • MsBuild never end

    - by senzacionale
    <Target Name="RunWebServer"> <Exec Command='$(WebServer) /port:3811 /path:$(Path)' /> </Target> command is actually this command: "C:\Program Files (x86)\Common Files\microsoft shared\DevServer\9.0"\WebDev.WebServer /port:3811 /path:"D:\PROJEKTI\eMedicine\eMedicine\eMedicine" but when i start build.xml D:\PROJEKTI\eMedicine\eMedicine>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MsBuild.exe Build.xml /target:RunWebServer Microsoft (R) Build Engine Version 3.5.30729.4926 [Microsoft .NET Framework, Version 2.0.50727.4927] Copyright (C) Microsoft Corporation 2007. All rights reserved. Build started 15.5.2010 14:06:36. script never end. How can is run it and then automatically stop it and prepeare for next Task?

    Read the article

  • problem with connection of facebook in my app for iPhone

    - by Arun Sharma
    hello I have complete code of facebook connection. But When i dragged the complete code into my application then 112 errors will occurs. wherever i have use use that code "FBConnect/FBConnectGlobal.h"Then error will arises "FBConnect/FBConnectionGlobal.h" No such file or directory. Even i have given all the path in project setting/project active setting. So please tell me some solution how to rectify some solution. and also tell me exact place where i have set the path and what to give in that path Thanks

    Read the article

  • How do I dynamically specify a file in DOS?

    - by donde
    I am trying to use c# in .net to run dos commands to ftp a a file. Technically, it calls a BAT file which calls a CMD file which executes the DOS code. It was up to the CMD file. The CMD fiel will work if I hardcode the path, but I need to dynamically specify the path of the file. BAT File... ftp.exe -s:%~dp0\mycmdfile.cmd And in the cmd file... open <my ost> <my user name> <my pw> quote site cyl pri=1 sec=1 lrecl=1786 blksize=0 recfm=fb retpd=30 put <here is where I need the dynamic path> + localfilename remotefilename quit

    Read the article

  • How to load image form NSMutableArray

    - by pbcoder
    I want to load the image URL from my NSMutableArray. Here is my Code: id path = (NSString *)[[stories objectAtIndex: storyIndex] objectForKey: @"icon"]; NSURL *url = [NSURL URLWithString:path]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImage *img = [[UIImage alloc] initWithData:data cache:NO]; If I use: id path = @"http://www.xzy.de/icon.png"; it´s all right, but not if I want to extract the imageURL from my Array Anyone who can help me? Thanks!

    Read the article

  • Different ways to specify libraries to gcc/g++

    - by abigagli
    I'd be curious to understand if there's any substantial difference in specifying libraries (both shared and static) to gcc/g++ in the two following ways (CC can be g++ or gcc) CC -o output_executable /path/to/my/libstatic.a /path/to/my/libshared.so source1.cpp source2.cpp ... sourceN.cpp vs CC -o output_executable -L/path/to/my/libs -lstatic -lshared source1.cpp source2.cpp ... sourceN.cpp I can only see a major difference being that passing directly the fully-specified library name would make for a greater control in choosing static or dynamic versions, but I suspect there's something else going on that can have side effects on how the executable is built or will behave at runtime, am I right? Andrea.

    Read the article

  • How do you create a writable copy of a sqlite database that is included in your iPhone Xcode project

    - by Iggy
    copy it over to your documents directory when the app starts. Assuming that your sqlite db is in your project, you can use the below code to copy your database to your documents directory. We are also assuming that your database is called mydb.sqlite. //copy the database to documents NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"mydb.sqlite"]; if(![fileManager fileExistsAtPath:path]) { NSData *data = [NSData dataWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/mydb.sqlite"]]; [data writeToFile:path atomically:YES]; } Anyone know of a better way to do this. This seems to work ...

    Read the article

  • Codeigniter Write_file Question

    - by Brad
    I am writing to a txt file to back up certain posts. Here is my simple code $this->path = APPPATH . "post_backups/"; $string = $this->input->post('post'); $post_title = $this->input->post('post_title'); $this->file = $this->path . $post_title."txt"; write_file($this->file, $string); $this->index(); Every thing works fine except this $this->file = $this->path . $post_title."txt"; I am trying to name my file with the title of the post IE: title.txt. What I am getting it s this "titletxt". How should the $post_title . "txt" be written to provide txt as an extension? Thanks

    Read the article

  • How to enable i18n from within setup_app in websetup.py ? (formatted resend)

    - by daniel
    From within the setup_app function (websetup.py) of a pylons i18n application, which is making use of a db, I was trying to initiate multilingual content to be inserted into the db. To do so the idea was something like: #necessary imports here def setup_app(command, conf, vars): .... for lang in langs: set_lang(lang) content=model.Content() content.content=_('content') Session.add(content) Session.commit() Unfortunately it seems that it doesn't work. the set_lang code line is firing an exception as follows: File ".. i18n/translation.py", line 179, in set_lang translator = _get_translator(lang, **kwargs) File ".. i18n/translation.py", line 160, in _get_translator localedir = os.path.join(rootdir, 'i18n') File ".. /posixpath.py", line 67, in join elif path == '' or path.endswith('/'): AttributeError: 'NoneType' object has no attribute 'endswith' Actually I'm even not sure it could be possible launching i18n mechanisms from within this setup_app function without an active request object. Anyone has tried some trick on a similar story ?

    Read the article

  • Zend Framework Autoloader question.

    - by Andre
    In zend framework I register my namespace like this (in application.php): 'autoloaderNamespaces' => array( 'Cms_' ) And after this - I'd expect that Zend would always check that path in addition to Zend and ZendX paths if unknown class is called. But for some reason this doesn't work with for example view helpers. I still have to register a separate path for my view helpers even though view helper scripts are named according to Zend coding standards and are located in: Cms/View/Helper/ And this is how I register helper path in config file: view' => array( 'charset' => 'UTF-8', 'doctype' => 'XHTML1_TRANSITIONAL', 'helperPath' => array( 'Cms_View_Helper_' => 'Cms/View/Helper' ) ), So - I'm not sure why I have to register "Cms" namespace twice first through 'autoloaderNamespaces' and then through View "helperPath"? Shouldn't Cms namespace include Cms/View/Helper namespace? can someone plz clarify this:)

    Read the article

< Previous Page | 135 136 137 138 139 140 141 142 143 144 145 146  | Next Page >