How to check if the file already exists in the client directory

Hi all.
I'm on devsuite 10g. I'm using webutil to download files from DB using webutil function db_to_client.
What I need is to check if the file already exists in the client directory and if yes to display a message to ask the user if he wants to overwrite or no. How can I make this???
Here is the code that I'm using to download the file.
Thanks all for the collaboration.
Fabrizio
declare
file_path varchar2(2000) := null;
BEGIN
/** I ask where saving the file on the client machine **/
file_path:= webutil_file.file_selection_dialog
(directory_name => null,
file_name => :bin_docs.name,
file_filter => '',
title => 'Saving file',
dialog_type => save_file, --save_file
select_file => TRUE);
/** I download the file from DB to client **/
if webutil_file_transfer.DB_To_Client_With_Progress
( file_path ,
'BIN_DOCS',
'DOC' ,
'doc_id = '||:bin_docs.doc_id,
'Downloading file',
' '||:bin_docs.name) then
msg_alert('Download del file avvenuto con successo','I',false);
else
msg_alert('Si è verificato il seguente errore in fase di download '||SQLERRM,'I',false);
end if;
end;

How about something like the below:
Note: I have a yes/no alert to asking if they want to over-write the existing file.
DECLARE
file_path VARCHAR2(2000) := null;
over_write BOOLEAN := TRUE;
BEGIN
/** I ask where saving the file on the client machine **/
file_path:= webutil_file.file_selection_dialog
(directory_name => null,
file_name => :bin_docs.name,
file_filter => '',
title => 'Saving file',
dialog_type => save_file, --save_file
select_file => TRUE);
IF webutil.file_exists(file_path) THEN
/** check a file by the same name exists in the selected directory **/
IF show_alert('Ask_overright') != alert_button1 THEN
/** If we say no then set over_write value to false **/
over_write := FALSE;
END IF;
END IF;
IF over_write THEN
/** I download the file from DB to client **/
IF webutil_file_transfer.DB_To_Client_With_Progress
( file_path ,
'BIN_DOCS',
'DOC' ,
'doc_id = '||:bin_docs.doc_id,
'Downloading file',
' '||:bin_docs.name) then
msg_alert('Download del file avvenuto con successo','I',false);
ELSE
msg_alert('Si è verificato il seguente errore in fase di'
||' download '||SQLERRM,'I',false);
END IF
END IF;
END;
cheers
Q

Similar Messages

  • How to check if a file already exists or not

    javax.swing.filechooser.FileFilter filter = new FileNameExtensionFilter("CSV Files","csv");
                   final JFileChooser fileSelect = new JFileChooser();
                   fileSelect.addChoosableFileFilter(filter);
                   int action = fileSelect.showSaveDialog(JFrame)
                   try{
                        if (action == JFileChooser.CANCEL_OPTION)
                             return;
                        else if (action == JFileChooser.APPROVE_OPTION)
                             SwingUtilities.invokeLater(new Runnable()
                                  public void run()
                                       file = fileSelect.getSelectedFile();
                                       JOptionPane.showMessageDialog(null,file);
                                       if (!file.exists())
                                            JOptionPane.showMessageDialog(null,file.isDirectory());
                                       //fetches the file name from the file name filed in the GUI
                                       final String fileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       if(!fileName.endsWith(".csv"))
                                            //appends the file type to the fetched filename
                                            ((BasicFileChooserUI)fileSelect.getUI()).setFileName(fileName + ".csv");
                                       final String newFileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       //replace the oldfile with filename.csv
                                       String csvFile = file.getPath().replace(file.getPath().substring(file.getPath().lastIndexOf('\\') + 1,file.getPath().length()),"");
                                       file = new File(csvFile.concat(newFileName));
                                       if(file.exists())
                                            JOptionPane.showMessageDialog(null,file);
                                            int response = JOptionPane.showConfirmDialog (null,
                                                      "Overwrite existing file?","Confirm Overwrite",
                                                      JOptionPane.OK_CANCEL_OPTION,
                                                      JOptionPane.QUESTION_MESSAGE);
                                            if (response == JOptionPane.CANCEL_OPTION)
                                                 return;
                                            else
                                                 try
                                                      writeToFile();
                                                 catch (IOException e)
                                                      e.printStackTrace();
                                       else
                                            try
                                                 writeToFile();
                                            catch (IOException e)
                                                 e.printStackTrace();
                   catch(Exception e)
                        e.printStackTrace();
                   }

    Thank u very much
    I got the solution for it
    if(ae.getActionCommand().equals("Export"))
                   data= new Vector();
                   data.addAll(tabData);
                   javax.swing.filechooser.FileFilter filter = new FileNameExtensionFilter("CSV Files(*.csv)","csv");
                   final JFileChooser fileSelect = new JFileChooser();
                   fileSelect.addChoosableFileFilter(filter);
                   int action = fileSelect.showSaveDialog(MainFrame.getMainFrame());
                   try{
                        if (action == JFileChooser.CANCEL_OPTION)
                             return;
                        else if (action == JFileChooser.APPROVE_OPTION)
                             SwingUtilities.invokeLater(new Runnable()
                                  public void run()
                                       file = fileSelect.getSelectedFile();
                                       //fetches the file name from the file name filed in the GUI
                                       final String fileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       if(!fileName.endsWith(".csv"))
                                            //appends the file type to the fetched filename
                                            ((BasicFileChooserUI)fileSelect.getUI()).setFileName(fileName + ".csv");
                                       final String newFileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       //replace the oldfile with filename.csv
                                       String csvFile = file.getPath().replace(file.getPath().substring(file.getPath().lastIndexOf('\\') + 1,file.getPath().length()),"");
                                       JOptionPane.showMessageDialog(null,csvFile);
                                       if (csvFile.endsWith("\\" + "\\"))
                                            csvFile = csvFile.concat(fileName.concat("\\"));
                                       file = new File(csvFile.concat(newFileName));
                                       if(file.exists())
                                            int response = JOptionPane.showConfirmDialog (null,
                                                      "Overwrite existing file?","Confirm Overwrite",
                                                      JOptionPane.OK_CANCEL_OPTION,
                                                      JOptionPane.QUESTION_MESSAGE);
                                            if (response == JOptionPane.CANCEL_OPTION)
                                                 return;
                                            else
                                                 try
                                                      writeToFile();
                                                 catch (IOException e)
                                                      e.printStackTrace();
                                       else
                                            try
                                                 writeToFile();
                                            catch (IOException e)
                                                 e.printStackTrace();
                   catch(Exception e)
                        e.printStackTrace();
    Message was edited by:
    vijaysforum

  • Try to check whether a file already exists on disk by using fileExists

    Hy all,
    i try to check whether a file already exists on disk in my
    Action scirpt.
    I found this link about fileExists:
    link
    So i tried somethink like this in my code, but without
    success...
    if(fl.fileExists("file:///C|/toto.txt"))
    {gotoAndPlay(2);}
    else
    {gotoAndPlay(3);}
    Is it not the right syntax?
    Thank you for your help.

    Did you build and application from the swf with mProjector?
    The only
    way this and other mProjector functions will get called is to
    post
    process your swf into and application (exe / app) using
    mProjector.
    you can get a free trial here
    http://www.screentime.com/software/mprojector/demo.html
    On 2007-01-08 16:02:42 -0500, "Alexis Schneider"
    <[email protected]> said:
    John Pattenden
    Screentime Media - Flash Tools since 1997
    http://www.screentime.com

  • How to check if a file (picture) exists into a war?

    Hello, I have made a Java/J2EE project using countries in the world and I have at my disposition a folder of flags icons.
    Some countries don't have any flag icon for any reason and in my application, I'll be able to add new ones.
    In my code, I want to do display the flag of the current country if available else display a default icon.
    Here is what I am currently doing:
    String contextPath = facesContext.getExternalContext().getRequestContextPath();
    String flagUrl = contextPath + "/images/flags/"+ name.trim().toLowerCase() + ".png";
    boolean exists = (new File(flagUrl)).exists();The issue is exists is always set to true no matter the existence of the flag.
    Here is what my variable nammed flagUrl looks like : /images/flags/ca.png
    How do you check the existence of a file into a war? Thank you
    Edited by: cotede3 on Mar 11, 2010 5:32 AM

    Unfortunately I cannot call getRealPath on application.
    application in my code is :
    BBrApplication application = null;
              // Searchs entity class icon
              FacesContext facesContext = FacesContext.getCurrentInstance();
              if (facesContext != null)
                   application = BBrApplication.getInstance(facesContext);So I tried
    String realFilePath = application.getContextRoot();but I end up with
    realFilePath = /DFP/.
    so It is not the absolute path displayed...
    How can I do ?

  • How to check whether the Application Server directory exits or not

    Hi,
    I have a selection screen in which I give the Application server file name(UNIX file) as input. Here, I would like to check whether the Server directory exists or not.
    Let us say, the path I gave in the selection screen is /usr/sap/tmp/testfile.txt . Here, the file name is testfile.txt and the server directory is /usr/sap/tmp . I would like to check whether this directory /usr/sap/tmp exists in the server or not. I am not bothered about the file name as I am going to write data into the file. I am mainly concerned about whether the directory exists in the server or not. and one more thing... this is the Application Server path not the Local path.
    Can anyone help me on the same how to check whether the server directory exists or not.
    Thanks in advance.
    Best Regards,
    Pradeep.

    Also you can use the FM EPS_GET_DIRECTORY_LISTING for this purpose.
      Store the directory name
        l_dpath = p_file+0(l_no).
      Validate the directory of the application server
        CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
          EXPORTING
            dir_name               = l_dpath
          TABLES
            dir_list               = l_i_dlist
          EXCEPTIONS
            invalid_eps_subdir     = 1
            sapgparam_failed       = 2
            build_directory_failed = 3
            no_authorization       = 4
            read_directory_failed  = 5
            too_many_read_errors   = 6
            empty_directory_list   = 7
            OTHERS                 = 8.
      If any problem occurs with the directory then display proper
      error message
        IF sy-subrc <> 0.
        Display error message
          MESSAGE e018 WITH 'Problem with directory entered'(008).
        ENDIF. " sy-subrc <> 0
    Regards,
    Joy.

  • How to check for the sub folder in the document library Is already Exist using CSOM?

    Hi,
    My requirement is to create the  folder and sub folder in SharePoint document library. If already exist leave it or create the new folder and the subfolder in the Document library using client side object model
    I able to check for the parent folder.
    But cant able to check the subfolder in the document library.
    How to check for  the sub folder in the document library?
    Here is the code for the folder
    IsFolder alredy Exist.
    private
    string IsFolderExist(string InputFolderName)
    string retStatus = false.ToString();
    try
    ClientContext context =
    new ClientContext(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryLink"]));
                context.Credentials =
    CredentialCache.DefaultCredentials;
    List list = context.Web.Lists.GetByTitle(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryName"]));
    FieldCollection fields = list.Fields;
    CamlQuery camlQueryForItem =
    new CamlQuery();
                camlQueryForItem.ViewXml =
    string.Format(@"<View  Scope='RecursiveAll'>
    <Query>
                                            <Where>
    <Eq>
    <FieldRef Name='FileDirRef'/>
    <Value Type='Text'>{0}</Value>
                                                </Eq>
    </Where>
    </Query>
                                </View>",
    @"/sites/test/hcl/"
    + InputFolderName);
                Microsoft.SharePoint.Client.ListItemCollection listItems = list.GetItems(camlQueryForItem);
                context.Load(listItems);
                context.ExecuteQuery();
    if (listItems.Count > 0)
                    retStatus =
    true.ToString();
    else
                    retStatus =
    false.ToString();
    catch (Exception ex)
                retStatus =
    "X02";
    return retStatus;
    thanks
    Sundhar 

    Hi Sundhar,
    According to your description, you might want to check the existence of sub folder in a folder of a library using Client Object Model.
    Please take the code demo below for a try, it will check whether there is sub folder in a given folder:
    public static void createSubFolder(string siteUrl, string libName, string folderServerRelativeUrl)
    ClientContext clientContext = new ClientContext(siteUrl);
    List list = clientContext.Web.Lists.GetByTitle(libName);
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =
    @"<View Scope='RecursiveAll'>
    <Query>
    <Where>
    <Eq>
    <FieldRef Name='FSObjType' />
    <Value Type='Integer'>1</Value>
    </Eq>
    </Where>
    </Query>
    </View>";
    //camlQuery.FolderServerRelativeUrl = "/Lib1/folder1";
    camlQuery.FolderServerRelativeUrl = folderServerRelativeUrl;
    ListItemCollection items = list.GetItems(camlQuery);
    clientContext.Load(items);
    clientContext.ExecuteQuery();
    Console.WriteLine(items.Count);
    if (0 == items.Count)
    //create sub folder here
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to check whether a file exist in the program folder or not?

    Hi guys,
    how to check whether a file exist in the program folder or not? Let is say i recieve a file name from user then i want to know if the file is there not and act on that base.
    abdul

    Look at the class java.io.File and the .exists() method:
    http://java.sun.com/j2se/1.4/docs/api/java/io/File.html

  • Weird CS4 error when saving eps files on a Mac: "...specified files already exist in the target location"

    Hi There,
    All 3 workstations in our studio are experiencing weird file behavior when re-saving eps files from Illustrator.
    Basically Illustrator creates a new file in addition to the original and adds a "-01.eps" onto the file name. If you re-save your original, Illustrator brings up a dialogue box that states:
    Some of the specified files already exist in the target location. The files marked below will be replaced:
    filename.eps
    filename-01.eps
    We've been deleting the "-01.eps" files each time but it's becoming tedious. The behaviour occurs when re-saving an eps file to a server or the desktop.
    All machines are new Quad-core MacPros running:
    - Leopard 10.5.8
    - Illustrator CS4 14.0.0
    We've checked for Illustrator updates from within Illustrator but we seem to be running the latest version.
    Is anyone else experiencing this behavior?
    Any help or pointers in the right direction would be much appreciated.
    Cheers
    Ben

    Thanks for the reply.
    The error occurs when we save the document but if we choose save as, "Use Artboards" seems to be unchecked so not sure if this issue is related or not. Will re-save the document using save as then see if the issue persists.
    Why do we still use eps?
    Basically because we've found it to be much more compatible. Our entire logo library is in eps format (18 years worth) partly because it was previously the only format to use and partly because it allows account managers to send logos to clients, printers, TV stations etc and not involve the studio (saving out an eps version).
    Although "Create PDF compatible file" is a good idea, we've encountered costly issues with colours and images - especially if the recipient is using old CS software, non-Adobe software or is using some kind of hardware RIP. We now just go with what we know works.
    But I do find saving eps versions of everything to be a bit painful. In fact, I've always found Illustrator in general to be a bit painful when compared with Photoshop or AfterEffects. Illustrator seems like it's been developed by a different company some times!
    Cheers, and thanks for the help.

  • "file already exists in the destination" during application build

    I am trying to build an executable and have gotten the following error:
    The file already exists in the destination.
    C:\Program Files\National Instruments\LabVIEW 8.2\vi.lib\Sentech LV 82\Shared Library - Trigger SDK\StTrgApi.dll
    WHen I start the build I go to "Build Executable" then click "Build"
    The VI for the project I have open is the Startup VI and I do not list any Dynamic VIs or Support FIles.
    I am using Labview 8.2
    I installed a user library for a USB camera from Sentech wich I am using and it works fine in Labview 8.2
    When I try to do the build I get the error shown above. The file it is referencing is there along with the .lvlib file.
    I tried removing the file shown in the error message to see what would happen and I continue to get the same error even though the file is not there. I even restarted LV and still got the same error.
    I am new to the application builder (v7 ?) and have not been able to find any good tutorials. Does anyone have any ideas on this error or a good place to learn more about app builder.
    Thanks
    Keith

    I am new to the application builder (v7 ?) and have not been able to find any good tutorials. Does anyone have any ideas on this error or a good place to learn more about app builder.
    Thanks
    Keith
    Hi Keith,
    you can check this Link out for a tutorial on app builder.
    Regards,
    Denver 

  • How to check Whether the File is in Progress or used by some other resource

    Hi All,
    I am retrieving a file from the FTP server using Apache commons FTP.
    I need to check whether the file is fully retrieved or in progress.
    for now i can able to use the file which is partially retrieved. it is not throwing any file sharing exception or i am unable to find whether it is in progress.
    How to check whether the file is in progress ? or The file is accessed by some other resource ?
    Pls Help me.
    Thanks,
    J.Kathir

    Hi Vamsi,
    Explicitly such kind of requirement has not been catered and i dont think you would face a problem because any application that is writing to a file will open the file in the read only mode to any other simultaneous applications so i think your concerns although valid are already taken care off .
    In the remote case you still face a problem then as a work around. Tell the FTP administrator to set the property to maximum connections that can be made to ftp as one. I wonder if you have heard of the concept of FTP handle , basically the above workaround is based on that concept itself. This way only one application will be able to write.
    The file adapter will wait for its turn and then write the files.
    Regards
    joel
    Edited by: joel trinidade on Jun 26, 2009 11:06 AM

  • The cluster service terminated, error 7024, cannot create a file when that file already exists

    I have a test 2-node Failover cluster using Server 2012 R2
    As of last night the cluster service on one of the 2 nodes is down with this error:
    The Cluster Service service terminated with the following service-specific error: 
    Cannot create a file when that file already exists.
    EventID 7024
    The Cluster service waits 60 sec, tries to start, and the same error occurs again. 
    Any idea where to look to identify which file this error is referring to, or how to go about identifying root cause and getting a solution?
    thank you.
    samb

    Hi Yeswanth
    Then you can try with a "Add Counter". This will create new file each time with the same name but a counter will be added to the file name at the end specifying the number of times it is created.
    You can also the specify the format to create the counter once select this option u can correspondingly fill the Format and step fields.
    Will this be fine.
    Regards
    Ashmi

  • How to fix 'file already exists, code 6' cs5.03 win7 64bit bluray please

    hello,
    at the last part of a 31gb bluray h264 iso image burn
    encore stops responding for 20 minutes (disappears from task manager
    and performance monitor entirely) and then says 'code 6 file already exists'
    the same error has occurred twice at the very end of the build
    i cleared the preferences each time
    any help is appreciated...
    jeffrey

    hello,
    after a lot of reading and
    some digging, figured out
    how my system does things:
    when you tell encore to write a bdmv folder
    you come out with 2 folders: bdmv and a temp folder
    using image burn you load up the first bdmv folder which contains
    the streams, etc.
    then tell image burn to load up the certificate folder
    which is hiding in the temp/db/certificate directory
    very clever...
    disc burns successfully and menu navigation in tact on pc
    and on hdtv through set top bluray
    thanks for all the help...
    have a great day...
    jeffrey

  • JavaScript: How to check if a file exists.

    Hello Everybody,
    Can you tell me how to check if a file exists using JavaScript and Internet Explorer.
    Browsing on this website I could read about the command "f.exists()" and it was necessary to include "java.io.*".
    Should I use this same command and should I include the same files? Or are there other files and other commands?
    Thanks in advance.

    sorry ya. there is no command to check whether a file exists using javascript. The following code says the object name and value. But it can't say whether the file exists in the harddisk or .. Javascript cannot access database and system resources. If the file exists or not can be checked through the application (ASP, CFML, ..) you are using.

  • PSE 9 and 5 will not import - says the file already exists in the catalog !

    I've already wasted 2 days looking for answers to this. When someone buys this program, at least half of the price is paying for the database in the Organizer - yet even John Ellis himself, who seems to know more than anyone about it, has gone to Lightroom. This is bad coding!!!
    Upgraded from 5 to 9. If you read my previous posts, this took 2 days too, and phone help from a tech, because it would not install in my XP computer. It did upgrade the Organizer from 5, although many of the symbols are unusable and don't work to help me identify my tags. However, now I see that neither 5 nor 9 is able to look at a file and display thumbnails that are in it.
    I move files around a lot for my business. Any half-way good database should be able to find the missing files, and also add any new images. Say I have 10 images in file A, then add 2 more to make 12. It can't see the added images! Says can't import, the file already exists in the catalog.
    I tried: updating thumbnails, recover, repair, in both 5 and 9 - nothing works. to import the images that I can SEE in these folders! I read here  that it will not import files if the same name is somewhere else. That alone is a problem.  But I think it's more than that: even if the file used to be in another folder, folder B, it won't recognize that it's in folder A now!
    Since PSE9 uses sql db, shouldn't that be better than 5 and be able to do simple tasks like this?
    Any advice or similar experiences eagerly welcomed.

    Thank you for replying, dj paiqe.
    Do you mean the first little section that says photos may not be displaying? Yes, those just reveal hidden photos and are very basic. I did them.
    I guess we disagree about databases and what they are designed to do, or maybe I didn't explain this well.
    I did not move the images outside of the catalog: I move them to various folders, all already imported WITHIN the catalog, as I send them to various editors. (these are all drawings, not photos, and I do this professionally, so it needs to work).
    Folder A and Folder B and Folder C have already been imported into the catalog. So if I move 2 images from folder B into folder A, the Organizer is simply lost, says image already exists, and everything is totally screwed up, as the image is no longer in folder B, and it can't find it in folder A!!! The problem is, unless I memorize the image name, say Image 9, I can't tell it to reconnect, as there is no longer an image in front of me! So there are 2 images, without names, now nowhere to be found. Inefficient, to say the least.
    I've never tried Lightroom or Filemaker, but I cannot believe that they would lose data like this. I think it's the Folder coding that's not working in PSE, and I wanted this to work so badly!!!!!
    I am willing to do it the PSE way, since you now have captions, keywords, etc, and it is a very powerful database, when it works. I understand that one is supposed to move images within the Organizer, obviously. But now many images are disconnected. I could start all over importing, but is there any way to do that without losing tags and categories?

  • Error when creating a user - IAM-3010183 : An error occurred while checking if a user already exists with the Common Name generated.

    Error when creating a user - IAM-3010183 : An error occurred while checking if a user already exists with the Common Name generated.

    in OIM 11g R2
    Message was edited by: 2b3c0737-074f-48d0-a760-e24e3ed9a37c

Maybe you are looking for

  • Hardware Key Information??

    Hello All,                On what hardware change SAP Hardware Key depends??Does it depend on RAM,CPU or Motherboard??Which hardware component change will change my hardware key??

  • Working with spry data sets

    Hi, I have page that uses a spry data set called 'dsSupport', however i do not want to use a table to select the item in the list i am instead using a spry select box: <div spry:region="dsSupport"> <h1>Step1: Select your product:</h1> <form id="form1

  • Movies in Library missing when attempting to sync...

    I am unable to sync movies that are in my itunes library to my iPad. When I access the sync menu only a few of the movies I have in my library appear. What can I do to resolve this issue?

  • Photoshop Default Color Off

    I'm using PS CS4, with Vista and a Samsung SyncMaster 2033 monitor. I was receiving an error message each time I started Photoshop: "The monitor profile "Samsung - Natural Color Pro 1.0 ICM" appears to be defective. Please rerun your monitor calibrat

  • Auto option for BW

    Hi, I created a BlackandWhite adjustment layer in a layerSet. when I clicked the auto option in the property window, the default values has changed accordingly. While reviewing the log file (ScriptingListenerJS.log) i came to know the new values are