Advertisement
SokazGames

Untitled

Nov 9th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using System.Diagnostics;
  12.  
  13. namespace WallpaperFixer
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void button1_Click(object sender, EventArgs e)
  24.         {
  25.             string[] getFiles = Directory.GetFiles("C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles"); // getting all files under the jpg extention in themes location
  26.             string cashedName = Path.GetFileName(getFiles[0]);   // gets file name from array
  27.  
  28.             MessageBox.Show(cashedName);
  29.             OpenFileDialog ofd = new OpenFileDialog();  // Making new openfiledialog
  30.  
  31.             if (ofd.ShowDialog() == DialogResult.OK) { // Checking to see if dialog box is not canceled
  32.                 string imageName = ofd.FileName; // storing selected file name in a string variable
  33.                 MessageBox.Show(imageName);
  34.                 //File.Move(imageName,"C:\\Users\\ADMIN\\Desktop\\" + cashedName);
  35.                 for(int x = 0; x <= getFiles.Length; x ++){
  36.                 File.Delete(getFiles[x]);
  37.                 }
  38.                 //File.Move(imageName, "C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles\\" + cashedName)
  39.                 File.Copy(imageName,"C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles\\" + cashedName);
  40.             }
  41.         }
  42.  
  43.         private void button2_Click(object sender, EventArgs e)
  44.         {
  45.             Process.Start(new ProcessStartInfo()
  46.             {
  47.                 FileName = "C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles",
  48.                 UseShellExecute = true,
  49.                 Verb = "open"
  50.             });
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement