Setting a directory path

I'm finding that I can only edit all the files within a directory that the program runs in. Is there a way of setting a directory path and being able to play with the files within.
I've set the path with the "." before, but could not change anyything, not unless the program resides in the directory.
I saw setdirectory(), method but couldn't get it to work, is this only for File chooser.
File directory = new File(".");
File[] files = directory.listFiles();
for(int x = 0; x < files.length; x++)
                 if(files[x].isFile()) dim.addElement(files[x].getName());;
        }

Java doesn't have anything like chdir command. You can use relative paths from the default path or you can use an absolute path in a File object.
For example:
new File("c:\\windows\\system32\\cmd.exe").rename("c:\\windows\\system32\\newname.exe");

Similar Messages

  • Set default directory/path for SaveAs Dialog using WPG_DOCLOAD

    Hi, im trying to set the default directory/path for the SaveAs Dialog called by wpg_docload.download_file.
    I'm not able to find where I can specify the default path.
    Is it something like "htp.p('Content-Disposition: attachment; path=:PX_OUTPUT_DIR" ?
    Thx for your help !
    Here's a part of my code
    owa_util.mime_header( NVL(mime,'application/octet'), FALSE );
    htp.p('Content-length: ' || length);
    htp.p('Content-Disposition: attachment; filename="'||substr(fileName,INSTR(fileName,'/')+1)|| '"');
    owa_util.http_header_close;
    wpg_docload.download_file( lobLoc );
    /*********************/

    I don't believe you're allowed to set the directory path in the Content-Disposition (or any other) header. More accurately, you can set path in the filename, but browsers don't pay any attention to that, they only look at only the terminal filename.
    <p>According to RFC 2183, browsers are supposed to ignore any path information sent with the filename. Even though it's dated 1997, I believe this RFC is still in effect.
    <p>This was done as a security precaution against malicious web apps that might try to download into a system directory or other dangerous place. Also, browsers (usually) allow users to specify their own default download directories. Further, even if you could specify the path, you'd have to do it for any and all filesystems (Linux, Mac HFS, Mac OSX, Windows, etc etc).

  • Setting Prompt Directory path using a string variable?

    So when you define a Prompt you get the form P[promptname.wav] and all is good.  What we want to do is have that prompt name be retrieved from a prompt directory which is defined by a string.   So assume all your prompts have the same numbers like 1001.wav but the actual file is customized based on things like Sales/1001.wav and Marketing/1001.wav   and you want to have a StringValue DirectoryName set the Directory to Sales or Marketing.   The Script does not seem to support setting P["DirectoryName"/1001.wav] where Directory Name is a string variable.    Is there a solution to this other than changing the entire prompt to a string type and dropping the P[] data type entirely?   

    I am working with a similar issue.   It is simple enought to set the Prompt Directory but when it is a variable it seems to have different results.  The attached simple script is used to demonstrate Sam's recommendation.  The XML document is embedded in the script variable, so you dont need to create it.   So the script reaches into the XML document and pulls up the variable strDirectoryName and then adds "/" to it and then sets the strPromptDirectory.   I have done it three ways:  Hard coded, string value for prompt' and prompt data type resolved from string.  As you single step through the script you will find that all values populate appropriately, but only the hard coded play prompt actually plays the prompt.  The other two assemblies fail.  (Clearly it assumes the prompt 10001.wav is in the directory Generic/ if you want to try it).    Written in  Version 8.5 editor.  

  • Creating a DB_ENV environment/setting a directory path for db's in Windows

    I have a small visual studio 2005 c++ program where I am trying to specify which directory to open my database from. I use db_env_create to create my environment and then I try to use DB_ENV->set_data_dir to set my path but it keeps returning a non 0 number and not setting my path. Did I miss any steps?
    Thanks

    Here is an example that I tried and it is crashing at the set_cachesize.
    I don't set the cachesize it then crashes at the dbenv->open. Any idea why I am crashing? I am using Berkeley version 4.6.21 with Windows xp and visual studio 2005.
    Thanks.
    int ret;
    if ((ret = db_env_create(&dbenv, 0)) != 0)
         cout <<"Error Creating Database " << endl;
         return (1);
    if ((ret = dbenv->set_cachesize(dbenv, 0, 64 * 1024, 0)) != 0)
            cout << "Cache size error " << endl;
         dbenv->close(dbenv, 0);
         return (1);
    (void)dbenv->set_data_dir(dbenv, "C:\Documents and Settings");
    if ((ret = dbenv->open(dbenv, "C:\Documents and Settings\champ\My Documents\Visual  
         Studio 2005\Projects",DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | 
         DB_INIT_MPOOL | DB_INIT_TXN,0)) != 0)
           cout << "Cache size error " << endl;
           dbenv->close(dbenv, 0);
           return (1);
    }

  • Dynamic Configuration - Set Directory Path for File Receiver Adapter

    Hi Experts,
    I have a question regarding the dynamic configuration for the file adapter. Is it possible to set a directory path without a message mapping for the file receiver adapter? the problem is that I want to import a pdf document. this pdf document I want to store in a dynamic directory (depending on the filename). so I have to read the filename out of the dynamic configuration and generate (depending on the filename) a directory for this file. Is that possible without a message mapping? I cannot make a message mapping because the file has the pdf format and should not get changed.
    best regards
    Christopher Kühn

    Hi Gaurav,
    I use the ASMA (respectively the filename) for the sender adapter. After the pdf was imported into XI this filename is in the ASMA.
    But what then??? How can I get this filename with the help of the variable substitution? and if I have this filename I have to change this filename a bit to generate the name / path of the directory.
    Please explain it to me detailled
    Thanks and regards
    christopher

  • Can't set directory path in a JTextField

    I've tried to set some directory paths in a JTextField, but nothing displayed in that the JTextField. However, i can print the directory paths one at a time to the console. The following is the code and will explain what I am trying to do:
    fileDialog.showOpenDialog(this);
    File[] classpath = fileDialog.getSelectedFiles();
    if(classpath.length == 0)
    return;
    String cp = "";
    for(int i = 0; i<classpath.length; i++){
    //System.out.println(classpath.getPath());
    cp.concat(classpath[i].getAbsolutePath());
    System.out.println(cp);
    jTextField_cp.setText(cp);
    if I uncomment the first print statement,each path will be shown on a new line in the console. But when I want to print the pathes of the directories in one time( concatenate them first), there's no output at all (the second print statement), I only got some empty new lines in the console. Is it any problems with the use of "cp.concat()" method?

    I'm pretty sure that it'll work if you replace your concat line with this.
    cp = cp.concat(classpath.getAbsolutePath());Java strings are passed by the value of their references, so you are only manipulating the value of the reference, the the string itself, unlike other objects. To work around that, assign cp the new string returned from the concat method.

  • How can I set a new directory path for iPhoto lib & photos?

    I'd like to use an external drive to house all the iPhoto related files including the Library, data files and photos. I don't see an iPhoto Preference to set a different path. Is there another method to accomplish this? Should I edit the directory path as listed in the AlbumData.xml file?
    Thanks!

    Hi Nova,
    copy the ENTIRE iPhoto Library folder (in your Pictures folder) to the external.
    Launch iPhoto with the Option key held down.
    At the prompt choose to open another library
    Navigate to the library on the external and choose it.
    Once it opens on the external this is the library iPhoto will use.
    You can then delete the one on the internal or save it as backup or burn it for backup.

  • Terminal Command, how to set defaults write, make application(s) use directory path where file last saved?

    Does anyone know whether there's a terminal command to make all applications remember/use the last directory/path where I last saved a file?
    For example, let's say there are (10) ten PDF's on a website, and I want to use Preview.app to open and save each file to the same directory.
    Problem is, after each time I save a file, Preview.app doesn't automatically remember/use the last directory where I saved my file(s).
    Forcing me to navigate back to the same directory after each time I save a file; super-annoying.
    But, for some reason, when saving images from the web, Firefox remembers the last directory where I saved the file (jpeg).
    So I'm hoping there's some way, possibly a terminal command to set/force all applications (including Preview.app) to remember/use the directory/path where file(s) were last-saved.
    Anyone?

    Get the third-party utility Default Folder X 4.4.9.

  • Set directory path

    I have to call native applications from within my java application (using the Runtime.getRuntime().exec() method). That works fine but I need to change the current directory path to a specific path.
    How it is done to change the current directory path with java ?
    Steffen Kux.

    You can use one class of mine that I already posted to this forums some time ago...
    /** executes multiple commands in one shell
    * @author: Giorgio Maone
    import java.io.*;
    public class MultiExec {
    static final boolean IS_WIN=System.getProperty("os.name").toLowerCase().indexOf("win")==0;
    protected String shell=IS_WIN?"":"sh";
    public void setShell(String s) {
       shell=s;
    public String getShell() {
       return shell;
    public Process exec(String cmds[]) throws IOException {
      File f=File.createTempFile("muexec",".bat");
      PrintWriter out=new PrintWriter(new FileWriter(f));
      if(IS_WIN) out.println("@echo off");
      for(int j=0,len=cmds.length; j<len; j++)
        out.println(cmds[j]);
      out.close();
      f.deleteOnExit();
      return Runtime.getRuntime().exec(shell+" "+f.getCanonicalPath());
    public int execAndWait(String cmds[]) throws IOException {
       Process p=exec(cmds);
      new Pipe(p.getInputStream(),System.out).connect();
      new Pipe(p.getErrorStream(),System.out).connect();
      new Pipe(System.in,p.getOutputStream()).connect();
      int exitCode=-1;
      try {
       exitCode=p.waitFor();
       } catch(InterruptedException ex) {}
      return exitCode;
    static class Pipe {
       private InputStream in;
      private OutputStream out;
      public Pipe(InputStream in, OutputStream out) {
        this.in=in; this.out=out;
      public void connect() {
        new Thread() {
         public void run() {
          try {
           for(int b;(b=in.read())!=-1;) {
             out.write(b);
           out.flush();
         } catch(IOException ex) {}
       }.start();
    // Test code
    public static void main(String[] args) throws Exception {
    String path=args[0];
    String drive=path.indexOf(":")==1?path.substring(0,1):"";
    System.out.println("\nExit code:"+
      new MultiExec().execAndWait(
       new String[]{
        drive,
        "cd "+path,
        args[1];
    }

  • Firefox won't open following update. Can't open Profile Mgr, even when using entire directory path in cmd line

    I'm running Firefox on a Windows 7 machine. Firefox won't open following the latest update. I've read the help articles and it seems like I need to create a new profile because my settings have likely been corrupted. I'm unable to open Profile Mgr, even when using entire directory path in cmd line. I've tried the following commands in the command line:
    firefox -p
    "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -p
    Nothing happens with either command.
    I'm also running Norton Internet Security. I read a help article Re Virtual Browsing features possibly causing a problem. The article said to check the virtualization setting in the internet security software and to clear the virtual cache. I went thru all of the settings menus in Norton Internet Security version 21.6.0.32 and I didn't see anything that looked like 'virtualization" settings, so I assumed that this doesn't apply to me.
    If you have any ideas, I'd sure appreaciate your expertise!!

    ''arcandl [[#question-1038482|said]]''
    <blockquote>
    I'm running Firefox on a Windows 7 machine. Firefox won't open following the latest update. I've read the help articles and it seems like I need to create a new profile because my settings have likely been corrupted. I'm unable to open Profile Mgr, even when using entire directory path in cmd line. I've tried the following commands in the command line:
    firefox -p
    "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -p
    Nothing happens with either command.
    I'm also running Norton Internet Security. I read a help article Re Virtual Browsing features possibly causing a problem. The article said to check the virtualization setting in the internet security software and to clear the virtual cache. I went thru all of the settings menus in Norton Internet Security version 21.6.0.32 and I didn't see anything that looked like 'virtualization" settings, so I assumed that this doesn't apply to me.
    If you have any ideas, I'd sure appreaciate your expertise!!
    </blockquote>
    ''philipp [[#answer-670108|said]]''
    <blockquote>
    hello arcandl, when firefox isn't launching after you double-click on the shortcut this is sometimes also a sign of malware being active on a system.
    you might want to try running a scan with some different other security tools like the [http://www.malwarebytes.org/products/malwarebytes_free free version of malwarebytes] and [http://www.bleepingcomputer.com/download/adwcleaner/ adwcleaner] which are specialised in removing adware and browser hijackers.
    [[Troubleshoot Firefox issues caused by malware]]
    </blockquote>
    Phillip - You're a genius!!! I ran malwarebytes and it resolved my problem. Thank you so much!!!

  • How can I get rid of directory path in front of my folder names in Folder listing in Library mode???

    Im using the most recent version of Lightroom 5.3 (updated through CC - even though this has shown up on previous version) on Windows 7 and all the folders in my library are showing up with the directory path in front of my folder names. How can I get rid of this? I do not see any options in preferences to turn this off. I have also turned off preferences in Windows > Folder Options Control Panel "Display full Path in Title bar" option.
    I have Lightroom on several computers and have set up preferences the same on each workstation, and this only shows up on one workstation.
    Any help would be appreciated.
    You can see from the image  below how this is showing up.
    Thanks
    Thanks!

    Click the little down arrow/+ symbol  next the + - in the folders bar.

  • How To Find Oracle Home Directory Path...

    Hello,
    I am working on deployment of java web service on Oracle Application Server(LINUX) 10g, EBS - R12.
    I am working on other system and i want to deploy web service remotely on application server.
    And i am not getting the oracle home directory path. I want to find the home directory path remotely.
    so suggest me how to find out path of that.
    or weather i have to install jdevloper on server system and than i have to deploy it,
    or any other alternative way is available.
    Reply as soon as possible......

    Thanks for your reply.
    It's precisely the registry key which got tampered, and there's no ORACLE_HOME environmental variable(Or that too is tampered)
    Now,how to set it to one of the Oracle home directories?
    Regards,
    Bhagat
    !!!!!!!!!!!!!!!!!!!!

  • How to set the report path in a model plugin

    I am trying to figure out how to set the report path in a process model plug-in. I can seem to figure out how to get access to it. It seems like this would be a reasonable thing to do since the plug-ins are for results processing. Does anyone know how to do this? We typically use the Sequential process model but I am trying to keep my plug-in as independent of that as possible. 
    Thanks.
    Solved!
    Go to Solution.

    If I understand, you want your plug-in, when enabled, to alter the settings of any other instances of the NI report plug-in such that their reports share the same directory as your plug-in is configured to use.
    If so, your plug-in can access and modify the settings of all other plug-in instances. All instances are passed to all plug-in entries point in the plugins array sub-property of the ModelConfiguration parameter. You can iterate through this array. Any element of the array with a Base.SequenceFilename equal to "NI_ReportGenerator.seq" is an instance of the NI report plug-in. Its report options are stored in the element under PluginSpecific.Options.
    You can change the report options to what ever you want. Note that the ReportOptions model callback is called from the Initialize model-plugin entry point, so you might want to ensure that your changes are applied after that, so they aren't overwritten. To do that, you could make your changes in the the Initialize entry point of your plug-in, and ensure that your plugin runs last. To make it run last, you could set the FileGlobals.ModelPluginComponentDescription.Default.Base.RunOrder in your plug-in file to a value greater than 0, such as 1.0 (see TestStand Help>>Fundamentals>>Process Model Architecture>>Process Model Plug-in Architecture>>Structure of Plug-in Sequence Files>>Model Plug-in Entry Points>>Order of Entry Point Execution at Run Time).

  • Finding the directory path in java

    I need to check if a file exists or not before an action is taken. I used File class to get the handle of a file and and then used exist() function to check if it is there. But this function needs to full path to that file. I need to find a directory path at runtime as the application is deployed in different environment and wouldn't know the directory path in each environment. Could somebody help me on this. Thanks,

    fBut this function
    needs to full path to that file. I need to find a
    directory path at runtime as the application is
    deployed in different environment and wouldn't know
    the directory path in each environment. Well, that can only you know where this file is on the different platforms. So maybee you can provide it as a user-input, a parameter to the program or be set in a settings-file which the program reads.
    If you want the full path to the current directory where the java program runs, this works:
    File f=...;
    String absPath=f.getAbsolutePath();
    File absPathFile=new File(absPath);Gil

  • Change directory path dynamically using UTL_FILE

    I have a directory TEST_DIR which points to /test/files/
    CREATE OR REPLACE PROCEDURE file_exist (v_country in varchar2) is
    v_check_file_exist BOOLEAN;
    v_dir VARCHAR2 (256) := 'TEST_DIR';
    begin
    UTL_FILE.fgetattr (V_DIR || V_COUNTRY,'file123' ||'.txt', v_check_file_exist, v_a,v_b);
    IF NOT v_check_file_exist THEN
    DBMS_OUTPUT.put_line (TO_CHAR(from_date,'YYYYMMDD')||'.rds');
    END IF;
    END LOOP;
    I would like to change the directory path based on the country which is passed as input to the procedure
    exec file_exist('IND'), so in this case I want the procedure to look for file 'file123.txt' under path /test/files/IND.
    But this is not working..
    But when I change the directory to
    create or replace directory TESTDIR as '/test/files/IND' and then change my UTL_FILE.fgetattr (V_DIR,'file123' ||'.txt', v_check_file_exist, v_a,v_b)(removing || v_country, this time it works.
    am trying this as I have many country folders under the path like
    /test/files/IND
    /test/files/USA
    /test/files/AFR
    and want to change the direcotry path dynamically according to input given.
    Any suggestions

    Make sure that the directories you are trying to write to have been set up for UTL_FILE.
    Refer to UTL_FILE_DIR parameter or CREATE DIRECTORY privilege depending on what DB version you are on.
    HTH
    --Johnnie                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for