Results 1 to 5 of 5

Thread: How to get file name of class file?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    2

    How to get file name of class file?

    Hi,

    If I for example have a file called class1.vb with some subs and functions inside.

    1. I call another class called class2 from class1 and get an error in this class, how can I get the name of the file class1.vb?

    2. How can I get the name of the file class1.vb from code if i haven't any error?

    Best regards,
    Thomas

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How to get file name of class file?

    When debugging, you will get the error in which it mentions to you the offending property, method, class, etc. If it is a reference to a member of class1 from class2, right click and go to definition, it should take you there. Aside from that, knowing the type of the object you are dealing with should tell you enough to know that it is a class (which you placed in class1.vb)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    2

    Question Re: How to get file name of class file?

    Hi mendhak,

    Thanks for your answer.

    But I am looking for a way to get this information when the application is compiled and running on a computer without Visual Studio, I would like to save the information in a log file.

    Best regards,
    Thomas

  4. #4
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    In A House :)
    Posts
    291

    Re: How to get file name of class file?

    look up reflection
    --"Tap Dancing On The Brittle Edge Of Sanity"--

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to get file name of class file?

    When you run a compiled application the class1.vb file doesn't exist, so how can you get its name? class1.vb is a source file containing VB code. When you build your project all your source files get compiled into a single EXE file. That's the only file there is. When you deploy your app you deploy only the EXE. How can anything in that EXE give you the name of the class1.vb file?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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