Solved

System.IO.Path Question

Posted on 2006-10-29
2
838 Views
Last Modified: 2008-01-09
Hi

Why am i getting this error ?

Error      1      Cannot declare variable of static type 'System.IO.Path'      

When im using this statement

        System.IO.Path file;
        string filepath = file.GetDirectoryName(Application.StartupPath).Substring(0, file.GetDirectoryName(Application.StartupPath).IndexOf("\\bin"));

vbturbo
0
Comment
Question by:vbturbo
2 Comments
 
LVL 29

Accepted Solution

by:
Nightman earned 125 total points
ID: 17829146
Because System.IO.Path is a static type - creating a variable 'file' would require an instance of System.IO.Path, and because it is static this can't be done.
instead

Path.GetDirectoryName(Application.StartupPath).Substring(0, Path.GetDirectoryName(Application.StartupPath).IndexOf("\\bin"));

and make sure that you have 'using System.IO;' in the namespace as well.
0
 
LVL 18

Author Comment

by:vbturbo
ID: 17829680
Thanks that worked.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now