Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using System.Diagnostics;
- namespace WallpaperFixer
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string[] getFiles = Directory.GetFiles("C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles"); // getting all files under the jpg extention in themes location
- string cashedName = Path.GetFileName(getFiles[0]); // gets file name from array
- MessageBox.Show(cashedName);
- OpenFileDialog ofd = new OpenFileDialog(); // Making new openfiledialog
- if (ofd.ShowDialog() == DialogResult.OK) { // Checking to see if dialog box is not canceled
- string imageName = ofd.FileName; // storing selected file name in a string variable
- MessageBox.Show(imageName);
- //File.Move(imageName,"C:\\Users\\ADMIN\\Desktop\\" + cashedName);
- for(int x = 0; x <= getFiles.Length; x ++){
- File.Delete(getFiles[x]);
- }
- //File.Move(imageName, "C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles\\" + cashedName)
- File.Copy(imageName,"C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles\\" + cashedName);
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Process.Start(new ProcessStartInfo()
- {
- FileName = "C:\\Users\\ADMIN\\AppData\\Roaming\\Microsoft\\Windows\\Themes\\CachedFiles",
- UseShellExecute = true,
- Verb = "open"
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement