How do I simply check a directory to make sure there is a xml file there?? I don't need to load it > psuedo code
Code:try
{
string location = @"\My Documents\My Games\Something\Something";
check for (".xml");
}
catch
{
exception
}
Printable View
How do I simply check a directory to make sure there is a xml file there?? I don't need to load it > psuedo code
Code:try
{
string location = @"\My Documents\My Games\Something\Something";
check for (".xml");
}
catch
{
exception
}
System.IO.File.Exists(string filename)
Your Google-fu is weak young padawan....
Awesome thanks!
I got a problem
I am using this as the argument
only problem is - IF there is a xml document there - Which there is, it still going to the exceptionCode:if (File.Exists(GameRef.GetDocumentsDirectory + @"\My Documents\My Games\RPGBXL" + "*.xml"))
{
manager.ChangeScreens(GameRef.PopUpScreenLoadFile);
}
else
{
BeginException = true;
}
Looks like you are missing a backslash at the end of your path
Unless you are looking for RPGBXL*.xml
Pretty sure you can't pass a wild card to that method either. In the case of looking for any .xml file, use Directory.GetFiles.
Hi Bixel,
Hope below code helps yo.. even yo need to search for txt files change the *xml to *txt
DirectoryInfo dir = new DirectoryInfo(@"C:\Data");
FileSystemInfo[] files = dir.GetFileSystemInfos("*xml");
foreach (FileSystemInfo info in files)
{
Console.WriteLine(info.FullName);
}
to : ramkumarradhakrishnan
That helped A LOT!!!
here is successful code
Thanks!Code:DirectoryInfo dir = new DirectoryInfo(GameRef.GetDocumentsDirectory + @"\My Documents\My Games\RPGBXL");
FileSystemInfo[] files = dir.GetFileSystemInfos("*xml");
if(files[0] != null)
{
manager.ChangeScreens(GameRef.PopUpScreenLoadFile);
}
else
{
BeginException = true;
}