Solved

System.IO.Path Question

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 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