Deleting an old saved XML. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Deleting an old saved XML.

Last post 03-23-2006 07:52 PM by potpourri. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 10-04-2004 06:39 AM

    • BrownR
    • Top 200 Contributor
    • Joined on 08-14-2004
    • USA
    • Posts 54

    Deleting an old saved XML.

    Ok my first thought was to have the submit button look in my file where i have my users saving the xml file if they want to. But the submit has to be programmed if i wanted to add code. Correct?? So I went to the save button on the form. I have this

    var myPathdelete = XDocument.DOM.selectSingleNode("/dfs:myFields/my:test");
    myPathdelete = new ActiveXObject("Scripting.FileSystemObject");
    XDocument.DeleteFile(myPathdelete);
    XDocument.UI.Alert("Deleted");


    BUt there is no DeleteFile in XDocument . So what else can i do to look in that folder , see any old xml and delete all files left in there? Thanks.
  • 10-04-2004 11:41 AM In reply to

    Re: Deleting an old saved XML.

    You are correct that XDocument does not have any delete functionality.

    My question is why you keep flopping around your myPathdelete variable? First you set it to a point to the node my:text, then you change it into an ActiveX Object, then you try to delete the ActiveX Object using a method that doesn't exist.

    I think you were probably on the right track using the ActiveX Object... but you need to use the delete functionality of that ActiveX Object to do your work. This has nothing to do with XDocument... you are accessing the file system and doing your work there.

    You need to research the FileSystemObject to use that to do what you are trying to do.

    One thing to keep in mind is that your form will have to be full trust to use the FileSystemObject.

    Greg Collins [InfoPath MVP]
  • 10-05-2004 12:19 PM In reply to

    • BrownR
    • Top 200 Contributor
    • Joined on 08-14-2004
    • USA
    • Posts 54

    Re: Deleting an old saved XML.

    yes it is a full trusted form. I will let you know what I find.
  • 03-16-2006 12:25 AM In reply to

    Re: Deleting an old saved XML.

    Has anyone tried using DeleteFile method and actually worked?
    I tried deleting one of the xml infopath forms on sharepoint, but 'FileExists' method cant seems to be able to locate the file.

    This is the code snippet I used:

    var fso;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    XDocument.UI.Alert("about to delete " + filespec);
    if ( fso.FileExists(filespec) ) {
    XDocument.UI.Alert("file found");
    fso.DeleteFile(filespec);
    XDocument.UI.Alert("file deleted");
    }

    where 'filespec' is the file location string to be deleted like 'http://sharepointlocation.com/Forms/libraryfolder/filename.xml'.

    And my form template is fully trusted.

    Help anyone?
  • 03-17-2006 10:46 PM In reply to

    Re: Deleting an old saved XML.

    No idea here.
    Patrick Halstead
    Project Manager at Qdabra
  • 03-23-2006 05:44 PM In reply to

    Re: Deleting an old saved XML.

    You are not going to be able to delete files over HTTP regardless of what application you are using. Web servers (at least to my knowledge) are just not setup to do this.

    Two ideas come to mind:

    1 - Write your own little ASP page or something that will delete the file on the web server. This should only take a few lines of ASP code to make some kind of page that when you load uphttp://yourwebserver/folder/deleteFile.asp?file=_file_name_ in a browser the ASP script will delete it from the server.

    2 - Use the SharePoint web services to interact with your form libraries. I have a HowTohttp://infopathdev.com/howto/tutorials/default.aspx?i=7bc880f391b84ea9b3b45c6fbecc07c6 that talks about adding SharePoint list items via InfoPath, and that might give you a few pointers on where to start looking.

    Hope this helps, good luck!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-23-2006 07:52 PM In reply to

    Re: Deleting an old saved XML.

    hi Matt, thanks for the pointers :)

    For idea #1:
    - Sorry, but how to execute that ASP script from the infopath program?

    And which way would impose less load on the client side, Matt?
    Solution #1 or #2?
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.