dcsimg
Results 1 to 7 of 7

Thread: Open file in folder

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2013
    Posts
    120

    Open file in folder

    Hello, I'm trying to open a file in a folder on every user's desktop. The folder name is "ABC" and the file I want the open is a PDF document named, "Test".

    I have try with this code, but it doesn't work:

    Code:
    Dim path As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "ABC")
                    Process.Start(path & "Test.pdf")
    Any idea what is wrong... thanks for help

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,140

    Re: Open file in folder

    Have you actually looked to see what 'path & "Test.pdf"' produces? Why use Path.Combine to combine one pair of partial paths and then not use it the second time?

  3. #3
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,329

    Re: Open file in folder

    Questions like these could be answered if the OP stepped through the code. As John said look at the path, it's clearly not valid. To know what Path.Combine is surely you have read the documentation? then you would know Path.Combine Method (String, String, String)

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,140

    Re: Open file in folder

    Quote Originally Posted by ident View Post
    Questions like these could be answered if the OP stepped through the code. As John said look at the path, it's clearly not valid. To know what Path.Combine is surely you have read the documentation? then you would know Path.Combine Method (String, String, String)
    Actually, I didn't even know about that overload myself. I've been using Path.Combine since .NET 1.1 so I haven't read the documentation for that method for some time and the overloads that combine more than two partial paths were only added in .NET 4.0. The OP is using VS 2010 so they may well be targeting .NET 4.0 but, if not, they are limited to two partial paths per call. That simply means two calls for three paths thought.

  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,329

    Re: Open file in folder

    Yes but John you are not a new programmer and i can't see any reason why you would suddenly perform a Google request on basic documentation you know. The OP should of recently Googled Path.Combine Method and the top result displays it's Four overloads Path.Combine Methods. Are you aware of the other new overload Path.Combine Method (String())

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,140

    Re: Open file in folder

    Quote Originally Posted by ident View Post
    Yes but John you are not a new programmer and i can't see any reason why you would suddenly perform a Google request on basic documentation you know. The OP should of recently Googled Path.Combine Method and the top result displays it's Four overloads Path.Combine Methods. Are you aware of the other new overload Path.Combine Method (String())
    I agree completely. I wasn't suggesting that it was OK that the OP didn't check the documentation. As I'm sure you're aware, I'm a big proponent of all .NET developers of every level using the documentation. I was more pointing out that you'd shown me something new too but also explaining why that overload might not be available, which might have been confusing if an attempt had been made to use it and it wasn't found.

  7. #7
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,329

    Re: Open file in folder

    I think in the last Two years of reading you stress about the importants of reading documentation i think i can quite confidently say no other carpenter in the world spends as much time as i do reading MSDN

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width