|
-
Dec 18th, 2007, 01:16 PM
#1
Thread Starter
Addicted Member
[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
-
Dec 18th, 2007, 01:36 PM
#2
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
-
Dec 18th, 2007, 04:41 PM
#3
Fanatic Member
Re: [2.0] System.IO Help
Try looking at the FileInfo and DirectoryInfo classes in the System.IO namespace.
-
Dec 19th, 2007, 08:23 AM
#4
Thread Starter
Addicted Member
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.
-
Dec 19th, 2007, 08:41 AM
#5
Thread Starter
Addicted Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|