public static bool CanGenerate()
{
if (_canGenerate != null) return _canGenerate.Value;
try
{
//try to access the appdata path
object o = AddinAppData.Instance;
//try to access the install folder
var files = Directory.GetFiles(AddinAppData.Instance.ExtensionDirectory, "*.csproj");
if (files.Length > 0)
{
var fileData = string.Empty;
using (var sr = File.OpenText(files[0]))
{
fileData = sr.ReadToEnd();
}
}
//try to create a file in the install folder
var newFileName = Path.Combine(AddinAppData.Instance.ExtensionDirectory, Guid.NewGuid().ToString());
File.WriteAllText(newFileName, "test");
System.Threading.Thread.Sleep(500);
File.Delete(newFileName);
_canGenerate = true;
return true;
}
catch (Exception ex)
{
_canGenerate = false;
return false;
}
}