using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Configuration;
namespace ScrewTurn.Wiki {
///
/// Implements tools for local providers.
///
public static class LocalProvidersTools {
///
/// Checks a directory for write permissions.
///
/// The directory.
/// true if the directory has write permissions, false otherwise.
public static bool CheckWritePermissions(string dir) {
string file = System.IO.Path.Combine(dir, "__StwTestFile.txt");
bool canWrite = true;
System.IO.FileStream fs = null;
try {
fs = System.IO.File.Create(file);
fs.Write(Encoding.ASCII.GetBytes("Hello"), 0, 5);
}
catch {
canWrite = false;
}
finally {
try {
if(fs != null) fs.Close();
System.IO.File.Delete(file);
}
catch {
canWrite = false;
}
}
return canWrite;
}
}
}