Solved

System.IO.Path Question

Posted on 2006-10-29
2
850 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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