Results 1 to 5 of 5

Thread: [RESOLVED] [2.0] System.IO Help

  1. #1

    Thread Starter
    Addicted Member corwin_ranger's Avatar
    Join Date
    Sep 2004
    Location
    CT
    Posts
    198

    Resolved [RESOLVED] [2.0] System.IO Help

    I've been given a project which seems pretty simple at its face, but since I never really work in the System.IO namespace, I'm having a hard time getting the pieces together in my head.

    I'm not looking for someone to code this for me, just point me to the classes/methods and overall workflow I'll need.

    Ideally, this will be a console app that will parse the file names of a series of files in a given directory, then create directories in another locations and copy the appropriate files into them. It would take in two command line arguments representing the source and destination paths (ideally in either absolute OR relative path structure) then after parsing the arguments read the file names in the source directory and create the required directory structure in the destination and copy files appropriately.

    ex 1: myCopyApp.exe c:\Source d:\destination (absolute pathing)
    ex 2: myCopyApp.exe ..\Source ..\..\Destination (relative pathing)

    So the questions I have basically are:

    1. How do I properly parse the input parameters to establish whether either one is relative or absolute pathing?
    2. What classes in the IO namespace will I need to:
    a. Establish where my start drectory is in the case of relative pathing.
    b. Establish the source & destination directories that I'll be working with
    c. Create the new directories.
    d. Copy the files.

    Feel free to ask for more info if you need it. Again, I'm not looking for someone to code this for me. Just looking for the correct objects in the IO namespace and thoughts on parsing and dealing with relative pathing in those objects.

    Thanks
    Regards,

    Steve

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2.0] System.IO Help

    System.IO.Directory and System.IO.File (it might be .Directories and .Files, but close enought)... absolute vs. relative.... I *think*.... the GetFiles in the Directory class can accept relative paths...as does the .CopyFile method in .Files .... but I'm not sure... I've never actually tried.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: [2.0] System.IO Help

    Try looking at the FileInfo and DirectoryInfo classes in the System.IO namespace.

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  4. #4

    Thread Starter
    Addicted Member corwin_ranger's Avatar
    Join Date
    Sep 2004
    Location
    CT
    Posts
    198

    Re: [2.0] System.IO Help

    Thanks guys. That got me going. I am having trouble finding one member in one of those classes that I thought I saw before. I believe that there's a method/property that will return just the file name portion of a path.

    Optimally, for example, given a path of C:\Source\abc.PDF this method/property would return just "abc". In the end, I need to parse the file name for some data. Am I just missing something? It seems that I am.
    Regards,

    Steve

  5. #5

    Thread Starter
    Addicted Member corwin_ranger's Avatar
    Join Date
    Sep 2004
    Location
    CT
    Posts
    198

    Re: [2.0] System.IO Help

    Thank you all for your help. I was able to find what I needed. It was the System.IO.Path class. Specifically, there's a GetFileNameWithoutExtension() method.
    Regards,

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width