Getting file structure off system

Im trying to create a program which can read the directory stucture of a system and put it in a list of sum sort so i can process it.
my aim is to be able to represent the file structure in an xml document
i am totally lost and would just like to get a bit of a push in the right direction

The code snippet below shows how to move through all the directories of a specific drive on a computer.
public void traverse (File root) {
    // get all the files in this location
    File [] files = root.listFiles();
    System.out.println ("Visiting " + root.getPath());
    // move through each of them and look for directories
    for ( int i=0; i < files.length; i++) {
        // if this is a directory then investigate it by calling traverse again
        if ( files.isDirectory() ) {
traverse (files[i]);
else {
System.out.println ("File: " + files[i].getPath());
You can get the drive letters (on a windows machine) that are valid by calling the static .listRoots method of the File class. Be warned that running the above code on a big drive will take some time!
Jonathan

Similar Messages

  • Automated process to get files from iScala System to GRC system

    Hi,
    iScala connector program run on local iscala servers.files are zipped up and place on ftp sites to download.once downloaded basis team copy the contents of zip files to IN Directory on GRC server.comparision utility is then run to move the files from IN directory to OUT directory.data extractors for each iScala connector are then run.Once extractors are done job scheduled to update the management report.i need more automated manner process and easy way process.
    Thanks

    As mentioned by Alpesh, for non RTA system there isn't any automated way to load data to GRC apart from using RAR Data extraction functionality.
    However you can look into possibility of using Greenlight technologyu2019s solutions to see if they provide any RTA to iScala system. They have about 25+ out of box RTAs to different non-SAP systems. Also they have RTA Design Studio which you can use to create a custom RTA specific to your ERP/Legacy application.
    Regards,
    Amol

  • SSIS 2012 Script Task to Get File Properties

    Hello,
    I researched on how to grab a file properties such as file size, file modified date, etc and I came across the following
    link:
    I followed exact steps and when I went to execute the package, I got the following error:
    Below is the code:
    // C# code
    // Fill SSIS variables with file properties
    using System;
    using System.Data;
    using System.IO; // Added to get file properties
    using System.Security.Principal; // Added to get file owner
    using System.Security.AccessControl; // Added to get file owner
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_cb8dd466d98149fcb2e3852ead6b6a09.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    public void Main()
    // Lock SSIS variables
    Dts.VariableDispenser.LockForRead("User::FilePath");
    Dts.VariableDispenser.LockForWrite("User::FileAttributes");
    Dts.VariableDispenser.LockForWrite("User::FileCreationDate");
    Dts.VariableDispenser.LockForWrite("User::FileExists");
    Dts.VariableDispenser.LockForWrite("User::FileInUse");
    Dts.VariableDispenser.LockForWrite("User::FileIsReadOnly");
    Dts.VariableDispenser.LockForWrite("User::FileLastAccessedDate");
    Dts.VariableDispenser.LockForWrite("User::FileLastModifiedDate");
    Dts.VariableDispenser.LockForWrite("User::FileOwner");
    Dts.VariableDispenser.LockForWrite("User::FileSize");
    // Create a variables 'container' to store variables
    Variables vars = null;
    // Add variables from the VariableDispenser to the variables 'container'
    Dts.VariableDispenser.GetVariables(ref vars);
    // Variable for file information
    FileInfo fileInfo;
    // Fill fileInfo variable with file information
    fileInfo = new FileInfo(vars["User::FilePath"].Value.ToString());
    // Check if file exists
    vars["User::FileExists"].Value = fileInfo.Exists;
    // Get the rest of the file properties if the file exists
    if (fileInfo.Exists)
    // Get file creation date
    vars["User::FileCreationDate"].Value = fileInfo.CreationTime;
    // Get last modified date
    vars["User::FileLastModifiedDate"].Value = fileInfo.LastWriteTime;
    // Get last accessed date
    vars["User::FileLastAccessedDate"].Value = fileInfo.LastAccessTime;
    // Get size of the file in bytes
    vars["User::FileSize"].Value = fileInfo.Length;
    // Get file attributes
    vars["User::FileAttributes"].Value = fileInfo.Attributes.ToString();
    vars["User::FileIsReadOnly"].Value = fileInfo.IsReadOnly;
    // Check if the file isn't locked by an other process
    try
    // Try to open the file. If it succeeds, set variable to false and close stream
    FileStream fs = new FileStream(vars["User::FilePath"].Value.ToString(), FileMode.Open);
    vars["User::FileInUse"].Value = false;
    fs.Close();
    catch (Exception ex)
    // If opening fails, it's probably locked by an other process
    vars["User::FileInUse"].Value = true;
    // Log actual error to SSIS to be sure
    Dts.Events.FireWarning(0, "Get File Properties", ex.Message, string.Empty, 0);
    // Get the Windows domain user name of the file owner
    FileSecurity fileSecurity = fileInfo.GetAccessControl();
    IdentityReference identityReference = fileSecurity.GetOwner(typeof(NTAccount));
    vars["User::FileOwner"].Value = identityReference.Value;
    // Release the locks
    vars.Unlock();
    Dts.TaskResult = (int)ScriptResults.Success;
    Eventually I am looking to just grab the Modified Date from the Windows Explorer folder and insert into table. Any suggestions? Thank you in advance!
    Sanjeev
    Sanjeev Jha

    Hi SSISJoost,
    I am so glad you responded to this thread. You are absolutely right. I copied the entire code including the project name (guid) and that solved the error problem.
    Now, what did you do to get the message box? I added the watch and I could see the values but how do I get these values in a table? If I remember correctly, in your blog, you mentioned something about using derived columns. I am familiar with Derived Columns
    but how do I do that? I appreciate your response.
    Thank you.
    Sanjeev
    Sanjeev Jha
    I used a second script task to show all variable values. It has a
    MessageBox in it and between all
    variables I added a
    newline to make it more readable...
    But with an Execute SQL Task and parameters you can also put these values in a Table... or you can read the file in a Data Flow Task and add those variables (as metadata) to each record with a Derived Column
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Need help understanding Time Capsule file structure and how to get it back

    I have the original Time Capsule on which I backup both my Mac Pro and my wife’s Macbook. When Snow Leopard came out, I successfully used the ‘Restore from Time Machine’ feature on my Mac Pro so I know it has worked. However, my wife’s MacBook harddrive died the other day and I was trying to do the ‘Restore from Time Machine’ and all it would find was a backup from April (when I put her in a new larger drive). Time Machine would not find any backup files newer that April. She stated that she had seen the the Time Machine backup notices regularly and as recent as the day the haddrive died (Nov. 23) so I figured that I should have no problem. Here is what I have found in my trouble shooting and what leads to my questions below.
    This is the file structure I found: (note that our ID’s are ‘Denise’ and ‘John’)
    *Time Capsule* (the drive as listed in my Finder window sidebar under ‘shared’)
    >Folder called ‘Time Capsule’ (when logged in as either ‘Denise’ or ‘John’)
    >>Denise Sparsebundle
    >>>Backup of Denise’s iBook (mounted image)
    >>>>Folder called ‘Backups.backupdb’
    >>>>>Folder called ‘Denise’s iBook
    >>>>>>Single folder with old April backup (not the right files)
    >>John Sparsebundle
    >>>Backup of John’s Mac Pro (mounted image)
    >>>>Folder called ‘Backups.backupdb’
    >>>>>Folder called ‘John’s Mac Pro’
    >>>>>>Folders containing all my backup files
    >Folder Called ‘Denise’ (if logged as ‘Denise’)
    >>Denise’s Sparsebundle (a disk image)
    >>>Backup of Denise iBook (the mounted image. Name from old machine)
    >>>>Backups.Backupdb
    >>>>>Denise’s iBook (Contains the backup I need)
    >Folder Called ‘John’ (if logged in as ‘John’)
    >> (empty)
    For some reason, my wife’s backup files are stored within a folder located at the top level of the Time Capsule drive called ‘Denise’, however, mine are within a folder called ‘Time Capsule’ which is at the same level as the ‘Denise’ folder.
    For some reason, when trying to use Time Machine to recover, it bypasses the top level ‘Denise’ folder which contains the correct files and goes into the ‘Time Capsule’ folder and finds the outdated backup files.
    I would assume that both my backup files and my wife’s should be at the same level of the Time Capsule.
    I was eventually able to use Migration Assistant to recover the files after installing a fresh OS and mounting the correct Sparsebundle image.
    So, my question, how do I get this fixed so that if I have to recover a drive with Time Capsule, it will find the correct files.
    Sorry for the long post and thanks in advance for any help.

    John Ormsby wrote:
    What I was trying to determine is why different backups for one particular machine are located at different file structure levels on my Time Capsule and why the most resent one for that machine is at a different level that for my other machine. Also, what is the correct level that both machines backups should be at.
    well John, first can you clarify if you are on 10.4.8 as your profile suggests ? if so, i'm wondering how you can use TM at all because TM was introduced with Leo. if you're not on 10.4.8, please update your profile. if you could, please also indicate details of your machine such as available RAM, processor, etc.
    second, what OS is your wife's machine running ?
    third, i frankly don't know too much about TM's file structure or if there indeed is such a thing as the correct one. however, i do know that it is best to leave TM to do its thing (as long as it's working). FWIW, though off-topic, you may want to have a look at this read for further information.
    last but not least, i see TM backups to my TC only as a part of my backup strategy. the backbone of my strategy is to create bootable clone of my startup disk(s) using e.g. Carbon Copy Cloner on a regular basis. while TM is capable of doing a full system restore, i don't trust it as much as a working clone. i use TM to retrieve a file i accidentally trashed a week ago but you cannot boot from a TM backup if your startup disk goes belly up.
    If I have missed this information in either the FAQs or the Troubleshooting article, I would greatly appreciate being pointed to it .
    i expect you didn't miss anything and i'm sorry you didn't find any help there. perhaps if Pondini (author of the FAQ and troubleshooting user tips) reads this thread, you will get the necessary advice on the file structure and more besides.
    good luck to you !

  • Is there a way to read data off drive, not relying on file structure somehow?

    That might be the wrong question. But it kind of gets at what I'm after. I have a DVD disk which was written by my TV DVD machine. While it was recording onto the disk, it ran out of space. When this happens, when I put the disk into my computer, my computer show zero files on there. Whereas if it hadn't of run out of space, a folder and a few files inside would appear. How can I access what's on the disk in this state? Is there a way to get the data off and turn it into a file?; there is data on the disk but my computer is showing zero files. Thanks.

    Some, if not all DVD Recorders (i.e. SA 8300 and Cablevision) use a proprietary file system that matches the drive to the device, so not only can it not be read by a computer, it won't even work when read by another SA 8300 device.  (Found this out when my SA 83000 cable box crashed.  My recording on an external drive could not be read by the new SA 8300).
    If you want to backup the files to another drive, you may be able to do a block-by-block copy.

  • Sender File Adapter  not able to get file via FTP from an external system

    Hi,
    I have a Sender File Adapter using FTP which polls a server every 10 seconds looking for a file ".xml".  The adapter will connect and pick up the waiting file, but sometimes the adapter not able to get file via FTP from an external system. The file is on the server, but despite the polling, the adapter does not pick up it. There is no return error.
    The connect mode is Permanently and the transfer mode is Binary.
    Can you help me?
    Thanks.
    T.

    Hi Teresa,
    does this case appears with a file size higher the others?
    Personally, I do not recommend to have a polling under 1min.
    10s could be too just, if the file is not small and/or if the file server is far (several kilometers) to where the Adapter Engine is, and/or this file server is beside a firewall. Do not forget also that, with previous points, you could have like a conflict, betwen the 1st polling and the 2nd polling, if in less 10s PI adapter has not enough time: to connect to the FTP server (several Km), find the file (perhaps among 100 other files in the directory), go back to the file to Adapter Engine server (several Km again), convert your file to XML message (with a complex Content Conversion), then check the XML structure, and when all that is done, return back to FTP server (several Km), to archive the source file... Well It's my understanding of a FTP exchange with FILE adapter...
    If you really need a 10s polling, that's mean your have a pseudo real time interface. In that case, in my mind file should not be used! but we should use a Web service, JDBC JMS (any exchange without a physical object like a file). For me, it's a non-sens to have a file in that case.
    regards.
    mickael

  • IWeb file structure and naming system

    I am trying to publish my iWeb directly to my domain (www.jessewarren.net) using the FTP direct publish function. However, iWeb is applying an overly complex naming system.
    For example, its publishing not only the page names, but also the name of the Site in iWeb, after the original URL. Here's an example: http://jessewarren.net/testing/Site/Blank.html
    First, I need everything to be on the domain. Then, I only need the name of the individual pages to be published, not the Site Name itself. I already have a site name, and that's my domain.
    Any other advice on how to control file structure and naming in iWeb?

    This is not incorrect and it is the way iWeb publishes and has done ever since iWeb 06. When you publish from iWeb to a local folder, what you get is your Site folder with your site name and a separate index file.
    If you don't want your site name included, then what you need to do is rather than using the direct ftp from iWeb, select ftp to a local folder instead. Your site will then be published to your desktop. Then download either Cyberduck or Transmit for free - these are dedicated ftp programs. Then all you do is load just the contents of your site folder to your public_html folder on your server and your url will then be http://www.domain.com/pagename.html.
    Be aware though, that if you are loading like this, you are breaking iWeb site structure and RSS feed will not be available to you if you need to use it.
    If you want to continue to use the built in iWeb ftp, then you could try naming your site public_html and then leaving the directory blank and then uploading like this and because you have named your site public_html and are uploading to the same place, your public_html folder on your server will be replaced with your website, thus eliminating the site name.
    I have tried this method once myself with my own site and it does work, however, I still prefer to publish to a folder and then upload to my sever using Cyberduck.

  • Getting files off an early 2000's hard drive

    My fiance has an early 2000's laptop that the screen is broke and no power cord.  I have removed the hard drive and put in an enclosure that works and is recognized by my pc at work but not able to see what's on it as it doesn't recognize the file structure.  I have hooked it up to my imac at home and nothing has happened.  What do i need to do to get the files off it?

    A: does the HD spin up (listen for same) hooked to your Imac?
    B: hooked to your Imac at home does the external HD show up in disk utility?
    great job on yanking the HD from the dead Mac and tossing it into an enclosure. I hope its not a 'DYNEX' enclosure you bought at the local electronics retail shop

  • Is there a way to get an apple mail folder exported to outlook mail folder structure?  I'm using Gmail on my IMAC and have a PC for work.  Want to share folder structure between systems.

    Is there a way to get an apple mail folder exported to outlook mail folder structure?  I'm using Gmail on my IMAC and have a PC for work.  Want to share folder structure between systems.

    Use following steps to import apple mail to outlook:     
    Choose Mailbox->Export Mailbox, or choose Export Mailbox from the Action pop-up menu
    Choose a folder or create a new folder where you want to store the exported mailbox.
    Outlook for Mac: Choose File->Import Mailboxes. Select the mail application you want to import messages from.
    If it does not work then you should use third party apple mail to pst applications. You can easily search in Google about these applications.

  • Is there any way for me to get my music off of my iPod?  I had to get a new computer and no longer have my files...but most are cds

    Is there any way for me to get my music off of my iPod? I had to get a new computer and no longer have my files, most of it is cds...

    Your iPod can only be synced with one computer at a time.  If you try to sync it with a new computer/iTunes library, it will replace the contents of the iPod with whatever is in the new library. You should probably disable the autosync functionality first by going to Edit -> Preferences, clicking the Devices tab, and enabling the prevent iPods,iPhones, and iPads from automatically syncing option.
    Before doing anything else,  authorize the new computer with your iTunes Account.  In iTunes, choose Store -> Authorize This Computer and enter in the correct credentials. Either copy a backup file from your old computer to your new one or create a new backup of your iPod in iTunes before letting it sync.
    Then right->click on your iPod Touch from under the Devices section in the left hand pane of iTunes and choose Backup. You might also want to take a look at this article to see what it all included in the backup.
    iOS: How to back up
    Now onto synced content such as music, videos, photos, etc.  For iTunes purchases you can copy them back into iTunes by choosing File -> Transfer Purchases.  For all other nonpurchased iTunes content, see this excellent user tip from another forum member turingtest2 outlining the different methods and software available to help you copy content from your iPod back to your PC and into iTunes.
    Recovering your iTunes library from your iPod or iOS device
    Once the backup has been made and all other synced content such as music, videos, and photos are back in your iTunes library, restore your iPod from that backup you made earlier.  Here is more on backing up and restoring your iPod.
    iTunes: Backing up, updating, and restoring iOS software
    If you do happen to lose any purchased content, you can always redownload it from the iTunes Store again at no cost via iCloud.  See this article for information.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    B-rock

  • How can i get the itunes off of my old iphone if the files on my computer have been erased?

    How can i get the itunes off of my old iphone if the files on my computer have been erased?

    1) ensure iTunes is authorized for your iTunes store account(s)
    2) connect your device and right-click or control-click it in the iTunes Source list, then choose transfer purchases from the shortcut menu that appears.
    3) sync the device
    iTunes will wipe the iPhone but, since you transferred your purchases in the previous step, your content will be in your library and you can re-populate the iPhone with it.
    above works for purchases from the iTunes store. for everything else, check out this post by Zevoneer.

  • I have a Mac Pro OS 10.7.5 and have a DVD+R disc with files on it, but it ejects the disk after about 10 seconds--what to do?  How can I get the data off this disc?  I can see it has been already burned, so files are on there?

    I have a Mac Pro OS 10.7.5 and have a DVD+R disc with files on it, but it ejects the disk after about 10 seconds--what to do?  How can I get the data off this disc?  I can see it has been already burned, so files are on there?

    Try cleaning the lens and see if that will restore functionality to the DVD drive.  Use a DVD lens cleaning disk, if you have a can of compressed air, shoot some into the slot or wrap a fine microfiber cloth (eyeglasses cleaning cloth)  around a business card and insert it gently inside the slot.
    If no success, make an appointment at an Apple store genius bar and get a free diagnosis from them.
    Ciao.

  • Data recovery, possible to get the file structure back as well?

    Hi Apple Smarties,
    I closed my laptop lid on my external LaCie drive without ejecting the drive first (smart one!). After that the external drive wouldn't mount. I've used Data Rescue 3 to recover all the files from the drive... however it's just lumping all the files into one big batch :-( ...anybody know if it's possible to get the files into the correct files structure they were at before the drive got corrupted?
    Assistance would be HUGELY appreciated.
    Many thanks
    Kind regards
    Doug

    Thank you Barry. Yes, Comcast is my mail provider. It is a POP account.
    Now, if you could point me in the right direction to do that re-build, I would be ever so grateful. I did use the "rebuild" button on the Mail tool bar for that box and it did not help. Perhaps there is something else I could do?
    As I mentioned, I am very new to the Mac world, and I get a little lost. Well, at age 73, I guess that's not hard to do! Been on Windows forever so lots of the terminology in Apple is quite different for me.
    Message was edited by: JanJones

  • HT1727 How do i get itunes to recognize music imported into the file structure?

    How do I get iTunes to recognize music imported into the file structure?

    Press Alt or Ctrl+B to reveal the menu bar if needed.
    Use File > Add Folder to Library if you just want to import it.
    If you're trying to relink broken entries in a library with the corresponding media then some more details would help.
    tt2

  • I have a G4 Quicksilver that no longer works, but the hd may still be good. How can I get files off the G4 hd and onto my new iMac?

    I have a G4 Quicksilver 2001 that no longer works, but the hd may still be good. How can I get files off the G4 hd and onto my new late 2013 iMac?

    Also, how do I boot the G4 into FireWire Target Disk mode?
    First, the G4 must be able to start to use FWTDM. If it can start, hold the t key at boot until you get a "screensaver pattern" that looks like this:
    If the G4 is attached via a FireWire cable to a newer Mac with a FireWire port, the G4's hard drive will appear on the other Mac's desktop just as if it were any external drive. A USB cable won't work for FWTDM.
    Just wondering if the drive in my G4, which I believe may be an ATA drive will also work in an enclosure for a SATA drive?
    No. ATA (actually "PATA" or "IDE") and SATA are different interfaces. PATA external enclosures are now very hard to find. You best and least expensive option is the adaptor that BDAqua linked. One of its connectors is for PATA drives.

Maybe you are looking for

  • Start Up Screen on thye Zen touch...it may work

    My option for changing the startup is not greyed out in Mediasource. I want to try it, but I want to be able to change it back to the original screen if I don't like the new test one. Anyone have a link to that image?

  • Oracle apps financial associate consultant responsibilities

    HI, what are the associate consultant roles & responsibilities? Thanks prasad.

  • Java for XI

    Hi Guys, I learned Java in Grad school. But since after my graduation I have been working only in ABAP. But after seeing XI world it seems its advantagous to know Java also. There are 1000s of websites for Java tutorial. Can someone guide me to compr

  • How to turn off the Screen Saver in 10.4.8

    I've been running tiger since 10.4.5 and do not want the OSX screen saver activated. Until now it has been sufficient to set screen saver to "never" in System preferences. After upgrading to 10.4.8, however, this does not prevent the screen saver fro

  • [svn] 2942: Add webapps/webtier/WEB-INF/flex/flex-sdk-description. xml to the ignore list.

    Revision: 2942 Author: [email protected] Date: 2008-08-21 07:52:24 -0700 (Thu, 21 Aug 2008) Log Message: Add webapps/webtier/WEB-INF/flex/flex-sdk-description.xml to the ignore list. Property Changed: flex/sdk/trunk/webapps/webtier/WEB-INF/flex/