Fixed help files.
This commit is contained in:
commit
b8f912cc79
1543 changed files with 395123 additions and 0 deletions
48
Core/LocalProvidersTools.cs
Normal file
48
Core/LocalProvidersTools.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
|
||||
namespace ScrewTurn.Wiki {
|
||||
|
||||
/// <summary>
|
||||
/// Implements tools for local providers.
|
||||
/// </summary>
|
||||
public static class LocalProvidersTools {
|
||||
|
||||
/// <summary>
|
||||
/// Checks a directory for write permissions.
|
||||
/// </summary>
|
||||
/// <param name="dir">The directory.</param>
|
||||
/// <returns><c>true</c> if the directory has write permissions, <c>false</c> otherwise.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue