Reputation: 23
im looking for a way to ignore this error message ( could not find a part of the path ). i mean my app is working with drive (F:) for exp. so if drive F not exist i will get the error message. how do i ignore or solve this?
my problem is that the path is not a folder and cannot be created...
string fdr = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
string fdrt = System.Environment.MachineName.ToString();
string fdrir = "F:\\";
Upvotes: 0
Views: 672
Reputation: 17868
There are a number of tools you can use:
if (Directory.Exists(pathhere)) dostuff else otherstuff;
try { dostuff; } catch { doingfailedmessages }
Both Directory and File give you chances to check for existance, but not for example in file if the file is in use already and locked. Where as try you try and do it and if it fails the you get to decide.. with the first you can try to eliminate the problem of failing in the first place.
Upvotes: 1