Variable file path

In File curfile1, I am fixing my path and sending that path in ReadFile. But I do not want to fix my path, instead whatever path I select while using my user interface should be my curfile1. My code below with fixed path is working fine:
private void fileButActionPerformed(java.awt.event.ActionEvent evt)
     JFileChooser chooser=new JFileChooser();
     chooser.setCurrentDirectory(curfile1);
     chooser.setMultiSelectionEnabled(true);
     int state=chooser.showOpenDialog(null);
     File[] files=chooser.getSelectedFiles();
     String[] filenames=getFilenames(files);
     for(int i=0;i<filenames.length;i++)
          try
                   ReadFile(curfile1,filenames);
          catch (IOException ex)
               ex.printStackTrace();
File curfile1=new File("D:\\temp\\");
Could anyone please tell me what updations I need to make in my code.

In my user interface when I select files from
any path other than D:\\temp\\, it's still
trying to locate those files in the path
D:\\temp\\, because I have mentioned as
File curfile1=new File(D:\\temp\\);. So please
tell me how to specify to pick up files from any
path. I do not want to fix my path.Why aren't you just removing new File("D:\\temp\\") in that case?
Kaj

Similar Messages

  • Get (variable) file path and name in a text element

    How do you get the (variable) file path and name in a text element (label) in LCD? If you save the PDF and afterwards relocate it, it should update the values. Is that actually possible?

    Does anyone have any advice on this issue?
    Thanks in advance,
    Zack H.

  • How to call a variable file path in javascript

    Hi,
    My objective is to capture a file path on mac and windows. However, this file path gets changed with various users.
    For example the path is:
    c:\user\username\AppData\Local\Temp\myfolder------> this is for windows machine
    /users/username/Library/Application Support/tempfolder/Temporary Files/-------> this is for mac machine
    As you can see, the path will be same for all the machines. Only the difference will be in searching the user and username at the start of file path. Rest folders will remain same on all the machines.
    Is there any grep pattern through which I can call this complete path in a variable for all the users.
    Any help will be appreciated.
    Regards,
    Abhi

    Hi,
    You are able to check OS:
    var currOS = $.os;
    regarding to value of this string you can switch to various paths
    Jarek

  • Formatting OLE object to variable file paths.

    I am currently using the trial version (2008) of Crystal Reports...at least for the next 7 1/2 days!  I have worked through all my problems/questions except one.  I am trying to insert a SolidWorks drawing document as an OLE object (linked) & the file path for the SW drawing needs to vary by the part name.  I placed a column in my Excel worksheet titled "Drawing File" & have tried several different formats to point the OLE to the correct file.  Thus far I am successful only in showing the original file the OLE object was created with.  The file path is Z:
    Jesse\Crystal Reports Tests\9-15-2009\FILENAME.slddrw
    I've tried adding hyperlinks to my Excel document, & I've typed out the address to the letter, but I just can't seem to get it to work.  Can anyone offer a solution here?

    I got the format right from the start.  Crystal '08 simply would not link to a SolidWorks file as it will a JPEG file (or any other picture file).  So be warned...if you want a SolidWorks drawing to show on your Crystal Report, you MUST save it as a picture file, which as SolidWorks users know, puts EXTREME limitations on a super product since your drawings & models are dynamically related.

  • Variable file paths

    I'm making an application to be distributed to people who will probably running a variety of operating systems, but I've encountered a slight problem:
    I want the installer program to install to a user-defined directory, but I don't know how to have the main program access the path to that directory. Is there some sort of universal resource my installer can write to/my main program can access to obtain the correct path?
    Thanks in advance

    My program has to know where the files it needs are located. I currently have it hardcoded, but obviously that would require me to re-compile for every user. I want the installer to get the desired directory from the user, write that to some sort of system resource, and have the main program read from that resource to find the directory.
    Plus, I can't use command line arguments because a) I'm using a JAR and b) most users don't know what a command line is.

  • Search c:\ drive and return file path for winword.exe and save as variable

    Hi all, here is what I'm trying to do;
    1. Search C:\ drive for winword.exe
    2. take the file path and save it as a variable.
    3. Then based on the path value, use the switch statement to run "some command" 
    Essentially I'm trying to find what the file path for winword.exe is, then run a command to modify the registry.  I already have the script that will modify the registry like I want but the problem it, the path is hard coded in the script, I want to
    now look for all versions of word and set the right file path so I can make the right registry changes.

    This should get you started:
    http://ss64.com/ps/get-childitem.html
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • SSIS - Loop through files from a file path based on the value in the variable

    Experts,
    I have a requirement where I'll be loading multiple files in to a SQL server table and archive the files when loaded. However, the challenge is , the file path should be dynamic based on the value of a variable (say, @ProductName).
    For example: If I am running the package for variable @ProductName="Product", the file path would be "\\....\Src\Product", in that case the ForEachLoop will loop through all the files in that folder, load them to the table and Archive
    the files to the "\\....\Src\Product\Archive" folder.
    Similarly, if the @ProductName="Product_NCP", the foreachloop container should loop through files in the "\\....\Src\Product_NCP" folder, load them to the table and archive them to the ""\\....\Src\Product_NCP\Archive"
    folder.
    Any suggestions? I should be able to run the package manually just by passing the "@Product" value, create Archive folder if it doesn't exist, load the data and archive the files.

    Yes
    1. Have a variable inside SSIS to get folder path. Set path based on your rule using an expression
    like
    (@[User::ProductName] == "Product" ? "\\....\Src\Product" : (@[User::ProductName] == "Product_NCP" ? \\....\Src\Product_NCP:..))
    similary archive
    (@[User::ProductName] == "Product" ? "\\....\Src\Product\Archive" : (@[User::ProductName] == "Product_NCP" ? "\\....\Src\Product_NCP\Archive" :..))
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Take Source file path in sender adapter from an environment variable .

    Hi,
    Is it possible to take source file path(half file path) dynamically in sender file adapter.
    Please suggest any alternative to this.

    Hi,
    One option, use Dynamic Configuration and set the values in the Mapping.
    By the ways, the File Directory and the Filename are taken runtime in the file adapters after transportation.
    Only if you are using FTP will you need to key in the FTP addess user id password etc.
    Refer -- same way try for File adapter
    Dynamic Configuration of Some Communication Channel Parameters using Message Mapping
    Ps Note : I have personally never tried it to use the Dynamic Configuration for file path. But you can try.
    Thanks
    Swarup

  • Variable being set to file path

    Hi,
    I am having trouble getting the file path of the file I want to use in my script. This is what my code is. Basically I move a file to the desktop, but if I want to use it on another computer, I want to specific finding the file by extension only.
    set orig_file to any file of folder "Desktop" of home whose name extension is ".plist"
    I need the /Users/username/Desktop/file.plist version of the file path.
    Any help would be appreciated!
    Thanks

    Use code such as:
    tell application "Finder"
    set orig_file to POSIX path of (item 1 of (get every file of folder "Desktop" of home whose name extension is “plist") as alias)
    end tell
    (117185)

  • Issue with length of file paths - Windows & C++ plugin

    Hello,
    I've got an issue that just popped up on my OCR plugin I've been working on that I suspect is related to the length of the filepath.
    I'm getting the following error that is being caught and logged when trying to open a file (filename changed for security purposes):
    Error Opening File: D:\aVeryLongFilePath.pdf
    Exception info: This file cannot be found.
    The entire string, including the D:\ part, is 266 characters long. I cut down the length of part of the path one by one and it was able to open and OCR the document when the length was 259 characters.
    I know there's a MAX_PATH variable in Windows and/or there's some kind of limitation for file length. Note that I can open the file in Acrobat using File->Open and run OCR on it individually using the built-in Recognize Text function, but if I try to Recognize Text for Multiple files and choose "Add Folders", the file in question doesn't show up in the list of files to be batch OCR'd (even though it is there). Interestingly, choosing "Add Files" from the Recognize Text->In Multiple Files does work. So Acrobat itself has at least some issues opening the file using some of it's features.
    Here's how I'm opening the document:
         string pn;               // assume this is initialized, I'm just putting this here to demonstrate what type it is
         pathName = pn;
         ASAtom pathType = ASAtomFromString("Cstring");
         asPathName = ASFileSysCreatePathName(ASGetDefaultFileSys(), pathType, pn.c_str(), NULL);    
         pdDoc = PDDocOpen(asPathName, ASGetDefaultFileSys(), NULL, true);
    Is there a way around this problem?
    Thanks.

    Yes, you are hitting the MAX_PATH on certain versions of Windows.   The only workaround would be to see that the file is "a very long path" and then break up the pathname construction into multiple pieces (perhaps the containing directory and then the file itself).  The other option is don't use Cstring to construct, use the Unicode variant.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Mon, 7 Nov 2011 15:43:33 -0800
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Issue with length of file paths - Windows &amp; C++ plugin
    Issue with length of file paths - Windows & C++ plugin
    created by zephed56<http://forums.adobe.com/people/zephed56> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4012710#4012710

  • How to get the current FILE PATH?

    I want to get the File Path on my Java Programming, which class / method can get a File Path on the windows?
    thanks!

    I want to get the current working directory(e.g.
    c:\Tomcat5.0\webapps\)
    If this is a web application you're talking about and you want the directory where that application is installed, that's almost certainly not the CWD. It might be one of the context or whatever variables that's available to servlets. Look in the servlet API and see what's there.

  • XsltCollaboration code file path exceeds 255 characters

    All,
    I'm trying to build a Deployment Profile for a CAPS project containing an XSLT Collaboration Definition. I managed to build the Deployment Profile previously with persistence turned off. After turning on persistence (Persistence for Reporting set to 'Yes' on the only Business Process in the project) and re-building the Deployment Profile I was greeted with an Exception dialog containing the following:
    com.stc.codegen.framework.model.CodeGenException: code generation error at = svcXCDXform - XCE CodeGen
    XsltCollaboration code file path
    C:\DOCUME~1\DAMIAN~1\LOCALS~1\Temp\builds\prjBPXformdpBPXform\svcXCDXform_ejb\xcdXform_Runtime_Handler.java
    exceeds 255 characters. Shorten XsltCollaboration name or recreate Connectivity Map with shorter name to solve this problemI don't think turning persistence on has anything to do with this error but mentioned it because that was the only change I made before re-building. Can anyone shed some light on why CodeGen is building in my local temp folder and not the Path which I have set in the Enterprise Designer | Build Options? Is this a completely different path?
    FYI - I am using Java CAPS 5.1.2.
    Thanks,
    Damian

    Change the Windows Environment Variables for the Temp folders to something like C:\TMP
    Not sure but i've noticed that the folder specified for CODEGEN_LOCATION is ignored in older versions of JCAPS.

  • Full file path in Office 2007 when open or save

    Am not sure i can raise this question here.
    We are using 10gR2 Application server and Windows 7 as a Client. In the client machine we have installed the Microsoft Office 2007.
    From the forms we are trying to open and save (after changes) the files of format Doc/Xls. These files will be stored in separate shared folder accessible through Application server and client.
    Now the issue is when we open/save the file it shows the Entire path (In Saving Window) which should not happen. In previous release of MS office its not like this.
    Please help us "to hide the file path to be displayed to the user". Like changing the registry for Office 2007 or workarounds or new solutions or any other oracle's product.
    Note : Showing the file name is the Office 2007s default behavior.

    The only way to avoid showing this from a Forms point of view would be to not display the open/save file dialog in the first place. In other words, control the opening and saving using your own custom dialogs. Also, be aware that using remote drives (network mapped) may cause problems. Generally speaking, doing this would not be considered supported.
    As for opening documents on the client, there is no need to use the open file dialog if you know the file name and path to that file in advance. You can simply use WebUtil's CLIENT_HOST. So let's say you wanted to open a file named mySales.doc and you knew its location, all you would need to do is this:
    Declare
         my_cmd varchar2(255);
    Begin
         my_cmd := 'rundll32 shell32,ShellExec_RunDLL '|| :t1;
         CLIENT_HOST(my_cmd);
    End;In the above example, +:t1+ is a text field on a canvas. The value would include the path and file name to be opened. Of course this could be a pl/sql variable which you programatically populate or any combination of that. The value value must include the full path (with drive letter) and full file name. If the path or name contains spaces, double quotes may likely be necessary. You will have to test.
    For saving an opened file, you are mostly out of luck from Forms unless you took control of Word/Excel as it was being opened in the first place. For example you likely can open the Office products using OLE or VB or other macro and control what the open and file save dialogs look like or if they are even accessible at all. But this has nothing to do with Oracle or specifically Forms.
    You need to refer to the MS documentation.

  • Win vs. Mac File Paths

    I have a script that Peter Kahrel helped me with (actually he pretty much wrote the whole thing). The script saves out each page of an Indesign doc as jpeg. It also takes the text from a text box tagged "jobnumber" and inserts it into the name of the saved jpeg.
    It works great on the Mac. When I move it over to Windows it inserts a weird character before and after the "jobnumber".
    On the Mac I can take the folder name which is a variable called 'path' and insert that into the filename as well but it doesn't work on Windows. Does anyone know what the differences are between Mac and Win paths in JS? I tried a few things to no avail.
    Here's the script:
    ==========================================
    var path = Folder.selectDialog ("Choose a Folder")
    app.jpegExportPreferences.resolution = 72;
    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
    app.activeDocument.sections.everyItem().includeSectionPrefix = false;
    //path = app.activeDocument.filePath + '/';
    p = app.activeDocument.pages.everyItem().getElements();
    for (i = 0; i < p.length; i++)
    jpg_name = p[i].textFrames.item ('jobnumber').contents + '.jpg';
    app.jpegExportPreferences.pageString = p[i].name;
    app.activeDocument.exportFile (ExportFormat.jpg, File (path + "/" + jpg_name));
    ===========================================
    As always, Thanks a million,
    Randy

    I forgot, here's a screenshot:
    http://reallyrandy.com/misc/screenshot2.jpg

  • Function module to get the file path in the system for TEMP folder

    Hi All,
    Is there any function module that I can use to get the file path in the system for TEMP folder.
    I mean, i am supposed to give only TEMP as the input for that function module and I need to get the path of that in the system as the output.
    I am unsing 4.0 version.
    Please advice.
    Regards
    Ramesh

    In Higher versions, we can use the below code:
    call method CL_GUI_FRONTEND_SERVICES=>ENVIRONMENT_GET_VARIABLE
        exporting
          VARIABLE   = 'TEMP'
        importing
          VALUE      = LV_TMP
        exceptions
          CNTL_ERROR = 1
          others     = 2.
      if SY-SUBRC <> 0.
        message id SY-MSGID type SY-MSGTY number SY-MSGNO
        with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      call method CL_GUI_CFW=>FLUSH
        exceptions
          CNTL_SYSTEM_ERROR = 1
          CNTL_ERROR        = 2
          others            = 3.
      if SY-SUBRC <> 0.
    Error handling
      endif.
      concatenate lv_tmp '\' into folder_path.
    But need to know in the lower versions like 3.1h and 4.0,

Maybe you are looking for