![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | elegant way to get path and file name Hello everyone, Suppose I have a string representing a file name (absolute name), like "c:\myproject\Csharpproject\memo.txt", I want to retrieve the path like c:\myproject\Cshartproject and relative file name memo.txt separately. thanks in advance, George |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: elegant way to get path and file name On Aug 26, 7:59*am, George <Geo...@xxxxxx> wrote: Quote: > Hello everyone, > > Suppose I have a string representing a file name (absolute name), like > "c:\myproject\Csharpproject\memo.txt", I want to retrieve the path like > c:\myproject\Cshartproject and relative file name memo.txt separately. > > thanks in advance, > George The Get-ChildItem Cmdlet returns a FileInfo object, which you can use to get these properties: PSH$ $file = Get-ChildItem "c:\myproject\Csharpproject\memo.txt" PSH$ $file.DirectoryName c:\myproject\Csharpproject PSH$ $file.Name memo.txt Jeff |
My System Specs![]() |
| | #3 (permalink) |
| Guest | RE: elegant way to get path and file name # PowerShell's Split-Path can do this for you: # parent path: split-path c:\myproject\Csharpproject\memo.txt -Parent # same as above, w/o the -Parent switch: split-path c:\myproject\Csharpproject\memo.txt # file name: split-path c:\myproject\Csharpproject\memo.txt -Leaf # ...and more: split-path c:\myproject\Csharpproject\memo.txt -Qualifier split-path c:\myproject\Csharpproject\memo.txt -NoQualifier split-path c:\myproject\Csharpproject\memo.txt -IsAbsolute -- Kiron |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: elegant way to get path and file name Thanks Jeff, Cool! regards, George |
My System Specs![]() |
| | #5 (permalink) |
| Guest | RE: elegant way to get path and file name Cool, Kiron! regards, George |
My System Specs![]() |
| | #6 (permalink) |
| Newbie | Re: elegant way to get path and file name I cannot even find out how to insert the path and filename anymore with Vista. Help. |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: elegant way to get path and file name What do you mean "insert the path and filename anymore", rsgreer? regards, George |
My System Specs![]() |
| | #8 (permalink) |
| Newbie | Re: elegant way to get path and file name I want to place a path and filename on all of my documents like I did in the older version, however, I cannot seem to find out how to do this ?? It is simple I am sure, I just don't see it. |
My System Specs![]() |
| | #9 (permalink) |
| Guest | Re: elegant way to get path and file name Thanks rsgreer, I think it is very clear in this discussion how to retrieve path and relative name parts of a absolute path file name. What is your specific confusion? :-) regards, George |
My System Specs![]() |
| | #10 (permalink) |
| Newbie | Re: elegant way to get path and file name You keep saying that but I haven't once seen someone write go to file, scroll down, add path and file name. If you are not able to write the directions we can stop this |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| finding path to an .exe file | Vista file management | |||
| Retrieve the path of the file | PowerShell | |||
| File Path Problem | Vista General | |||
| I miss the elegant simplicity........ | Live Mail | |||
| BUG? (Test-Path $path -IsValid) and empty $path | PowerShell | |||