Solved

System.IO.Path Question

Posted on 2006-10-29
2
839 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 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

14 Experts available now in Live!

Get 1:1 Help Now