Environment.SpecialFolder

  • Thread starter Thread starter A.Rocha
  • Start date Start date
A

A.Rocha

Hi,

In my mobile application i get de Path of "\\My Documents" folder with code
bellow

string DocPATH =
Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToString()

Its work fine, but if the User rename/delete (is stupid, but heapen) "My
Documents" folder i get an error.

How can i verify if folder exists before get the folder path without use
try/catch?

some like this.

string DocPATH
try
{
DocPATH =
Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToString();
}
catch
{
DocPATH ="";
}

Thanks for any help.
 
You can use System.IO.Directory.Exists(DocPATH) to verify that the folder
exists.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - software solutions for a mobile world
In The Hand Ltd - .NET Components for Mobility
 
First, specifically, what error do you get?

Second, why are you calling ToString()? If I'm not mistaking, GetFolderPath
returns a string.

-Drew
 
Back
Top