Solved

How to stay on the root directory

Posted on 2007-03-23
1
225 Views
Last Modified: 2010-04-16
Hi,

I have a property that looks like the following:

public static string RootDirectory
{
   get
   {
      string current = Directory.GetCurrentDirectory();
      string root = Directory.GetDirectoryRoot(current);
      return root;
   }
}

Somewhere while the program goes through its progression, the directory points to a mapped network drive called "Q:".  I would like to know how to remain on my root directory in which the application is running (in this case the C:\ drive).

Tnanks
0
Comment
Question by:brdrok
1 Comment
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 18780522
Either don't change directories in your program, or store the directory when your program starts to a static, and find your root off of that STORED directory rather than the current.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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