using System.Security.Principal;
using System.IO;
public ActionResult Index()
{
WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
WindowsPrincipal currentPrincipal = new WindowsPrincipal(currentIdentity);
if (currentPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
{
string temp = @"D:\", filename, destFile;
string[] files = Directory.GetFiles(temp, "*.jpg", SearchOption.TopDirectoryOnly);
foreach (string file in files)
{
filename = System.IO.Path.GetFileName(file);
destFile = System.IO.Path.Combine(@"D:\Images", filename);
System.IO.File.Copy(file, destFile, true);
}
}
return View("Index");
}