Exemple #1
0
 public static void SaveFile(HttpPostedFile file, string format, object arg0, object arg1, Dictionary<string, string> credentials)
 {
     using (Impersonate i = new Impersonate(credentials["user"], credentials["pass"], credentials["domain"]))
     {
         if (i.isImpersonated())
         {
             file.SaveAs(string.Format(format, arg0, arg1));
         }
     }
 }
Exemple #2
0
        public static void DeleteFile(string filepath,string filename, Dictionary<string,string> credentials)
        {
            using(Impersonate i = new Impersonate(credentials["user"],credentials["pass"],credentials["domain"]))
            {
                if (i.isImpersonated())
                {

                    var file = Directory.EnumerateFiles(filepath).FirstOrDefault(f => f.Contains(filename)).ToString();
                    File.Delete(file);
                }
            }
        }
Exemple #3
0
        public static string FileFinder(string directory, string filename, Dictionary<string, string> credentials)
        {
            using (Impersonate i = new Impersonate(credentials["user"], credentials["pass"], credentials["domain"]))
            {
                if (i.isImpersonated())
                {
                    bool contains = Directory.EnumerateFiles(directory).Any(f => f.Contains(filename));
                    if (contains)
                    {
                        var file = Directory.EnumerateFiles(directory).FirstOrDefault(f => f.Contains(filename)).ToString();
                        return Path.GetFileName(file);
                    }
                }
            }

            return string.Empty;
        }