Solved

System.IO.Path Question

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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